summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/expectations/should.rb
blob: 24b1cf2bf8570f0b9465f5d7e7ebdaf718f56eed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$: << File.dirname(__FILE__) + '/../../lib'
require 'mspec'
require 'mspec/utils/script'

# The purpose of these specs is to confirm that the #should
# and #should_not methods are functioning appropriately. We
# use a separate spec file that is invoked from the MSpec
# specs but is run by MSpec. This avoids conflicting with
# RSpec's #should and #should_not methods.

class ShouldSpecsMonitor
  def initialize
    @called = 0
  end

  def expectation(state)
    @called += 1
  end

  def finish
    puts "I was called #{@called} times"
  end
end

# Simplistic runner
formatter = DottedFormatter.new
formatter.register

monitor = ShouldSpecsMonitor.new
MSpec.register :expectation, monitor
MSpec.register :finish, monitor

at_exit { MSpec.actions :finish }

MSpec.actions :start
MSpec.setup_env

# Specs
describe "MSpec expectation method #should" do
  it "accepts a matcher" do
    :sym.should be_kind_of(Symbol)
  end

  it "causes a failue to be recorded" do
    1.should == 2
  end

  it "registers that an expectation has been encountered" do
    # an empty example block causes an exception because
    # no expectation was encountered
  end

  it "invokes the MSpec :expectation actions" do
    1.should == 1
  end
end

describe "MSpec expectation method #should_not" do
  it "accepts a matcher" do
    "sym".should_not be_kind_of(Symbol)
  end

  it "causes a failure to be recorded" do
    1.should_not == 1
  end

  it "registers that an expectation has been encountered" do
  end

  it "invokes the MSpec :expectation actions" do
    1.should_not == 2
  end
end