mspec 1.5.10 → 1.5.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/Rakefile +1 -1
  2. data/lib/mspec/commands/mkspec.rb +1 -1
  3. data/lib/mspec/expectations/expectations.rb +4 -4
  4. data/lib/mspec/expectations/should.rb +4 -4
  5. data/lib/mspec/guards/endian.rb +5 -8
  6. data/lib/mspec/guards/guard.rb +1 -1
  7. data/lib/mspec/helpers/const_lookup.rb +2 -1
  8. data/lib/mspec/helpers/flunk.rb +1 -1
  9. data/lib/mspec/helpers/io.rb +2 -2
  10. data/lib/mspec/helpers/ruby_exe.rb +6 -3
  11. data/lib/mspec/matchers/base.rb +14 -14
  12. data/lib/mspec/matchers/be_an_instance_of.rb +26 -0
  13. data/lib/mspec/mocks/mock.rb +5 -5
  14. data/lib/mspec/runner/context.rb +1 -1
  15. data/lib/mspec/runner/exception.rb +3 -3
  16. data/lib/mspec/runner/formatters/dotted.rb +2 -2
  17. data/lib/mspec/utils/name_map.rb +2 -1
  18. data/lib/mspec/utils/options.rb +3 -1
  19. data/lib/mspec/utils/script.rb +3 -2
  20. data/lib/mspec/version.rb +1 -1
  21. data/spec/commands/mkspec_spec.rb +2 -1
  22. data/spec/expectations/expectations_spec.rb +10 -10
  23. data/spec/expectations/should.rb +71 -0
  24. data/spec/expectations/should_spec.rb +58 -126
  25. data/spec/guards/endian_spec.rb +6 -6
  26. data/spec/helpers/flunk_spec.rb +3 -3
  27. data/spec/matchers/base_spec.rb +99 -90
  28. data/spec/matchers/be_an_instance_of_spec.rb +50 -0
  29. data/spec/matchers/be_close_spec.rb +2 -2
  30. data/spec/matchers/be_kind_of_spec.rb +5 -3
  31. data/spec/matchers/equal_utf16_spec.rb +12 -2
  32. data/spec/matchers/respond_to_spec.rb +5 -3
  33. data/spec/mocks/mock_spec.rb +22 -21
  34. data/spec/runner/actions/tally_spec.rb +2 -2
  35. data/spec/runner/actions/timer_spec.rb +4 -4
  36. data/spec/runner/context_spec.rb +4 -4
  37. data/spec/runner/exception_spec.rb +10 -10
  38. data/spec/runner/formatters/dotted_spec.rb +6 -6
  39. data/spec/runner/formatters/file_spec.rb +3 -3
  40. data/spec/runner/formatters/html_spec.rb +3 -3
  41. data/spec/runner/formatters/method_spec.rb +2 -2
  42. data/spec/runner/formatters/specdoc_spec.rb +5 -5
  43. data/spec/runner/formatters/summary_spec.rb +1 -1
  44. data/spec/utils/options_spec.rb +10 -9
  45. data/spec/utils/script_spec.rb +7 -6
  46. metadata +5 -2
@@ -0,0 +1,71 @@
1
+ $: << File.dirname(__FILE__) + '/../../lib'
2
+ require 'mspec'
3
+
4
+ # The purpose of these specs is to confirm that the #should
5
+ # and #should_not methods are functioning appropriately. We
6
+ # use a separate spec file that is invoked from the MSpec
7
+ # specs but is run by MSpec. This avoids conflicting with
8
+ # RSpec's #should and #should_not methods.
9
+
10
+ class ShouldSpecsMonitor
11
+ def initialize
12
+ @called = 0
13
+ end
14
+
15
+ def expectation(state)
16
+ @called += 1
17
+ end
18
+
19
+ def finish
20
+ puts "I was called #{@called} times"
21
+ end
22
+ end
23
+
24
+ # Simplistic runner
25
+ formatter = DottedFormatter.new
26
+ formatter.register
27
+
28
+ monitor = ShouldSpecsMonitor.new
29
+ MSpec.register :expectation, monitor
30
+ MSpec.register :finish, monitor
31
+
32
+ at_exit { MSpec.actions :finish }
33
+
34
+ MSpec.actions :start
35
+
36
+ # Specs
37
+ describe "MSpec expectation method #should" do
38
+ it "accepts a matcher" do
39
+ :sym.should be_kind_of(Symbol)
40
+ end
41
+
42
+ it "causes a failue to be recorded" do
43
+ 1.should == 2
44
+ end
45
+
46
+ it "registers that an expectation has been encountered" do
47
+ # an empty example block causes an exception because
48
+ # no expectation was encountered
49
+ end
50
+
51
+ it "invokes the MSpec :expectation actions" do
52
+ 1.should == 1
53
+ end
54
+ end
55
+
56
+ describe "MSpec expectation method #should_not" do
57
+ it "accepts a matcher" do
58
+ "sym".should_not be_kind_of(Symbol)
59
+ end
60
+
61
+ it "causes a failure to be recorded" do
62
+ 1.should_not == 1
63
+ end
64
+
65
+ it "registers that an expectation has been encountered" do
66
+ end
67
+
68
+ it "invokes the MSpec :expectation actions" do
69
+ 1.should_not == 2
70
+ end
71
+ end
@@ -1,129 +1,61 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'mspec/expectations/expectations'
3
- require 'mspec/matchers/base'
4
- require 'mspec/runner/mspec'
5
-
6
- class Object
7
- alias_method :rspec_should, :should
8
- alias_method :rspec_should_not, :should_not
9
- end
10
- require 'mspec/expectations/should'
11
- class Object
12
- alias_method :mspec_should, :should
13
- alias_method :mspec_should_not, :should_not
14
- alias_method :should, :rspec_should
15
- alias_method :should_not, :rspec_should_not
16
- end
17
-
18
- # Adapted from RSpec 1.0.8
19
- describe Object, "#should" do
20
- before :each do
21
- class Object; alias_method :should, :mspec_should; end
22
-
23
- @state = mock("example state", :null_object => true)
24
- context = mock("context state", :null_object => true)
25
- context.stub!(:state).and_return(@state)
26
- MSpec.stub!(:current).and_return(context)
27
- MSpec.stub!(:actions)
28
-
29
- @target = "target"
30
- @matcher = mock("matcher", :null_object => true)
31
- end
32
-
33
- after :each do
34
- class Object; alias_method :should, :rspec_should; end
35
- end
36
-
37
- it "accepts and interacts with a matcher" do
38
- @matcher.should_receive(:matches?).with(@target).and_return(true)
39
- @target.should @matcher
40
- end
41
-
42
- it "calls #failure_message when matcher #matches? returns false" do
43
- @matcher.should_receive(:matches?).with(@target).and_return(false)
44
- @matcher.should_receive(:failure_message).and_return(["expected", "actual"])
45
- @target.should @matcher rescue nil
46
- end
47
-
48
- it "raises an ExpectationNotMetError when matcher #matches? returns false" do
49
- @matcher.should_receive(:matches?).with(@target).and_return(false)
50
- @matcher.should_receive(:failure_message).and_return(["expected", "actual"])
51
- lambda {
52
- @target.should @matcher
53
- }.should raise_error(ExpectationNotMetError, "expected actual")
54
- end
55
-
56
- it "returns a PostiveOperatorMatcher instance when not passed a matcher" do
57
- matcher = should
58
- class Object; alias_method :should, :rspec_should; end
59
- matcher.should be_instance_of(PositiveOperatorMatcher)
60
- end
61
-
62
- it "invokes the MSpec :expectation actions" do
63
- MSpec.should_receive(:actions).with(:expectation, @state)
64
- @target.should @matcher
65
- end
66
-
67
- it "registers that an expectation has been encountered" do
68
- MSpec.should_receive(:expectation)
69
- @target.should @matcher
70
- end
71
- end
72
-
73
- describe Object, "#should_not" do
74
- before :each do
75
- class Object; alias_method :should, :mspec_should; end
76
- class Object; alias_method :should_not, :mspec_should_not; end
77
-
78
- @state = mock("example state", :null_object => true)
79
- context = mock("context state", :null_object => true)
80
- context.stub!(:state).and_return(@state)
81
- MSpec.stub!(:current).and_return(context)
82
- MSpec.stub!(:actions)
83
-
84
- @target = "target"
85
- @matcher = mock("matcher", :null_object => true)
86
- end
87
-
88
- after :each do
89
- class Object; alias_method :should, :rspec_should; end
90
- class Object; alias_method :should_not, :rspec_should_not; end
91
- end
92
-
93
- it "accepts and interacts with a matcher" do
94
- @matcher.should_receive(:matches?).with(@target).and_return(false)
95
- @target.should_not @matcher
96
- end
97
-
98
- it "calls #negative_failure_message when matcher.matches? returns true" do
99
- @matcher.should_receive(:matches?).with(@target).and_return(true)
100
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
101
- @target.should_not @matcher rescue nil
102
- end
103
-
104
- it "raises an ExpectationNotMetError when matcher.matches? returns true" do
105
- @matcher.should_receive(:matches?).with(@target).and_return(true)
106
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
107
- lambda {
108
- @target.should_not @matcher
109
- }.should raise_error(ExpectationNotMetError, "expected actual")
110
- end
111
-
112
- it "returns a NegativeOperatorMatcher instance when not passed a matcher" do
113
- matcher = should_not nil
114
- class Object; alias_method :should, :rspec_should; end
115
- matcher.should be_instance_of(NegativeOperatorMatcher)
116
- end
117
-
118
- it "invokes the MSpec :expectation actions" do
119
- MSpec.should_receive(:actions).with(:expectation, @state)
120
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
121
- @target.should_not @matcher rescue nil
122
- end
123
-
124
- it "registers that an expectation has been encountered" do
125
- MSpec.should_receive(:expectation)
126
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
127
- @target.should_not @matcher rescue nil
2
+ require 'rbconfig'
3
+
4
+ describe MSpec do
5
+ before :all do
6
+ path = Config::CONFIG['bindir']
7
+ exe = Config::CONFIG['ruby_install_name']
8
+ file = File.dirname(__FILE__) + '/should.rb'
9
+ @out = `#{path}/#{exe} #{file}`
10
+ end
11
+
12
+ describe "#should" do
13
+ it "records failures" do
14
+ @out.should =~ Regexp.new(Regexp.escape(%[
15
+ 1)
16
+ MSpec expectation method #should causes a failue to be recorded FAILED
17
+ Expected 1
18
+ to equal 2
19
+ ]))
20
+ end
21
+
22
+ it "raises exceptions for examples with no expectations" do
23
+ @out.should =~ Regexp.new(Regexp.escape(%[
24
+ 2)
25
+ MSpec expectation method #should registers that an expectation has been encountered FAILED
26
+ No behavior expectation was found in the example
27
+ ]))
28
+ end
29
+ end
30
+
31
+ describe "#should_not" do
32
+ it "records failures" do
33
+ @out.should =~ Regexp.new(Regexp.escape(%[
34
+ 3)
35
+ MSpec expectation method #should_not causes a failure to be recorded FAILED
36
+ Expected 1
37
+ not to equal 1
38
+ ]))
39
+ end
40
+
41
+ it "raises exceptions for examples with no expectations" do
42
+ @out.should =~ Regexp.new(Regexp.escape(%[
43
+ 4)
44
+ MSpec expectation method #should_not registers that an expectation has been encountered FAILED
45
+ No behavior expectation was found in the example
46
+ ]))
47
+ end
48
+ end
49
+
50
+ it "prints status information" do
51
+ @out.should =~ /\.FF\.\.FF\./
52
+ end
53
+
54
+ it "prints out a summary" do
55
+ @out.should =~ /0 files, 8 examples, 6 expectations, 4 failures, 0 errors/
56
+ end
57
+
58
+ it "records expectations" do
59
+ @out.should =~ /I was called 6 times/
128
60
  end
129
61
  end
@@ -9,13 +9,13 @@ describe Object, "#big_endian" do
9
9
  end
10
10
 
11
11
  it "yields on big-endian platforms" do
12
- @guard.stub!(:pattern).and_return([1])
12
+ @guard.stub!(:pattern).and_return([?\001])
13
13
  big_endian { ScratchPad.record :yield }
14
14
  ScratchPad.recorded.should == :yield
15
15
  end
16
16
 
17
17
  it "does not yield on little-endian platforms" do
18
- @guard.stub!(:pattern).and_return([0])
18
+ @guard.stub!(:pattern).and_return([?\000])
19
19
  big_endian { ScratchPad.record :yield }
20
20
  ScratchPad.recorded.should_not == :yield
21
21
  end
@@ -26,7 +26,7 @@ describe Object, "#big_endian" do
26
26
  end
27
27
 
28
28
  it "calls #unregister even when an exception is raised in the guard block" do
29
- @guard.stub!(:pattern).and_return([1])
29
+ @guard.stub!(:pattern).and_return([?\001])
30
30
  @guard.should_receive(:unregister)
31
31
  lambda do
32
32
  big_endian { raise Exception }
@@ -42,13 +42,13 @@ describe Object, "#little_endian" do
42
42
  end
43
43
 
44
44
  it "yields on little-endian platforms" do
45
- @guard.stub!(:pattern).and_return([0])
45
+ @guard.stub!(:pattern).and_return([?\000])
46
46
  little_endian { ScratchPad.record :yield }
47
47
  ScratchPad.recorded.should == :yield
48
48
  end
49
49
 
50
50
  it "does not yield on big-endian platforms" do
51
- @guard.stub!(:pattern).and_return([1])
51
+ @guard.stub!(:pattern).and_return([?\001])
52
52
  little_endian { ScratchPad.record :yield }
53
53
  ScratchPad.recorded.should_not == :yield
54
54
  end
@@ -59,7 +59,7 @@ describe Object, "#little_endian" do
59
59
  end
60
60
 
61
61
  it "calls #unregister even when an exception is raised in the guard block" do
62
- @guard.stub!(:pattern).and_return([0])
62
+ @guard.stub!(:pattern).and_return([?\000])
63
63
  @guard.should_receive(:unregister)
64
64
  lambda do
65
65
  little_endian { raise Exception }
@@ -9,11 +9,11 @@ describe Object, "#flunk" do
9
9
  MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
10
10
  end
11
11
 
12
- it "raises an ExpectationNotMetError unconditionally" do
13
- lambda { flunk }.should raise_error(ExpectationNotMetError)
12
+ it "raises an SpecExpectationNotMetError unconditionally" do
13
+ lambda { flunk }.should raise_error(SpecExpectationNotMetError)
14
14
  end
15
15
 
16
16
  it "accepts on argument for an optional message" do
17
- lambda {flunk "test"}.should raise_error(ExpectationNotMetError)
17
+ lambda {flunk "test"}.should raise_error(SpecExpectationNotMetError)
18
18
  end
19
19
  end
@@ -3,214 +3,223 @@ require 'mspec/expectations/expectations'
3
3
  require 'mspec/matchers/base'
4
4
  require 'time'
5
5
 
6
- describe PositiveOperatorMatcher, "== operator" do
7
- it "raises an ExpectationNotMetError when expected == actual returns false" do
6
+ describe SpecPositiveOperatorMatcher, "== operator" do
7
+ it "raises an SpecExpectationNotMetError when expected == actual returns false" do
8
8
  lambda {
9
- PositiveOperatorMatcher.new(1) == 2
10
- }.should raise_error(ExpectationNotMetError)
9
+ SpecPositiveOperatorMatcher.new(1) == 2
10
+ }.should raise_error(SpecExpectationNotMetError)
11
11
  end
12
12
 
13
13
  it "provides a failure message that 'Expected x to equal y'" do
14
- Expectation.should_receive(:fail_with).with("Expected 1\n", "to equal 2\n")
15
- PositiveOperatorMatcher.new(1) == 2
14
+ SpecExpectation.should_receive(:fail_with).with("Expected 1\n", "to equal 2\n")
15
+ SpecPositiveOperatorMatcher.new(1) == 2
16
16
  end
17
17
 
18
18
  it "does not raise an exception when expected == actual returns true" do
19
- PositiveOperatorMatcher.new(1) == 1
19
+ SpecPositiveOperatorMatcher.new(1) == 1
20
20
  end
21
21
  end
22
22
 
23
- describe PositiveOperatorMatcher, "=~ operator" do
24
- it "raises an ExpectationNotMetError when expected =~ actual returns false" do
23
+ describe SpecPositiveOperatorMatcher, "=~ operator" do
24
+ it "raises an SpecExpectationNotMetError when expected =~ actual returns false" do
25
25
  lambda {
26
- PositiveOperatorMatcher.new('real') =~ /fake/
27
- }.should raise_error(ExpectationNotMetError)
26
+ SpecPositiveOperatorMatcher.new('real') =~ /fake/
27
+ }.should raise_error(SpecExpectationNotMetError)
28
28
  end
29
29
 
30
30
  it "provides a failure message that 'Expected \"x\" to match y'" do
31
- Expectation.should_receive(:fail_with).with("Expected \"real\"\n", "to match /fake/\n")
32
- PositiveOperatorMatcher.new('real') =~ /fake/
31
+ SpecExpectation.should_receive(:fail_with).with(
32
+ "Expected \"real\"\n", "to match /fake/\n")
33
+ SpecPositiveOperatorMatcher.new('real') =~ /fake/
33
34
  end
34
35
 
35
36
  it "does not raise an exception when expected =~ actual returns true" do
36
- PositiveOperatorMatcher.new('real') =~ /real/
37
+ SpecPositiveOperatorMatcher.new('real') =~ /real/
37
38
  end
38
39
  end
39
40
 
40
- describe PositiveOperatorMatcher, "> operator" do
41
- it "raises an ExpectationNotMetError when expected > actual returns false" do
41
+ describe SpecPositiveOperatorMatcher, "> operator" do
42
+ it "raises an SpecExpectationNotMetError when expected > actual returns false" do
42
43
  lambda {
43
- PositiveOperatorMatcher.new(4) > 5
44
- }.should raise_error(ExpectationNotMetError)
44
+ SpecPositiveOperatorMatcher.new(4) > 5
45
+ }.should raise_error(SpecExpectationNotMetError)
45
46
  end
46
47
 
47
48
  it "provides a failure message that 'Expected x to be greater than y'" do
48
- Expectation.should_receive(:fail_with).with("Expected 4\n", "to be greater than 5\n")
49
- PositiveOperatorMatcher.new(4) > 5
49
+ SpecExpectation.should_receive(:fail_with).with(
50
+ "Expected 4\n", "to be greater than 5\n")
51
+ SpecPositiveOperatorMatcher.new(4) > 5
50
52
  end
51
53
 
52
54
  it "does not raise an exception when expected > actual returns true" do
53
- PositiveOperatorMatcher.new(5) > 4
55
+ SpecPositiveOperatorMatcher.new(5) > 4
54
56
  end
55
57
  end
56
58
 
57
- describe PositiveOperatorMatcher, ">= operator" do
58
- it "raises an ExpectationNotMetError when expected >= actual returns false" do
59
+ describe SpecPositiveOperatorMatcher, ">= operator" do
60
+ it "raises an SpecExpectationNotMetError when expected >= actual returns false" do
59
61
  lambda {
60
- PositiveOperatorMatcher.new(4) >= 5
61
- }.should raise_error(ExpectationNotMetError)
62
+ SpecPositiveOperatorMatcher.new(4) >= 5
63
+ }.should raise_error(SpecExpectationNotMetError)
62
64
  end
63
65
 
64
66
  it "provides a failure message that 'Expected x to be greater than or equal to y'" do
65
- Expectation.should_receive(:fail_with).with("Expected 4\n", "to be greater than or equal to 5\n")
66
- PositiveOperatorMatcher.new(4) >= 5
67
+ SpecExpectation.should_receive(:fail_with).with(
68
+ "Expected 4\n", "to be greater than or equal to 5\n")
69
+ SpecPositiveOperatorMatcher.new(4) >= 5
67
70
  end
68
71
 
69
72
  it "does not raise an exception when expected > actual returns true" do
70
- PositiveOperatorMatcher.new(5) >= 4
71
- PositiveOperatorMatcher.new(5) >= 5
73
+ SpecPositiveOperatorMatcher.new(5) >= 4
74
+ SpecPositiveOperatorMatcher.new(5) >= 5
72
75
  end
73
76
  end
74
77
 
75
- describe PositiveOperatorMatcher, "< operater" do
76
- it "raises an ExpectationNotMetError when expected < actual returns false" do
78
+ describe SpecPositiveOperatorMatcher, "< operater" do
79
+ it "raises an SpecExpectationNotMetError when expected < actual returns false" do
77
80
  lambda {
78
- PositiveOperatorMatcher.new(5) < 4
79
- }.should raise_error(ExpectationNotMetError)
81
+ SpecPositiveOperatorMatcher.new(5) < 4
82
+ }.should raise_error(SpecExpectationNotMetError)
80
83
  end
81
84
 
82
85
  it "provides a failure message that 'Expected x to be less than y'" do
83
- Expectation.should_receive(:fail_with).with("Expected 5\n", "to be less than 4\n")
84
- PositiveOperatorMatcher.new(5) < 4
86
+ SpecExpectation.should_receive(:fail_with).with("Expected 5\n", "to be less than 4\n")
87
+ SpecPositiveOperatorMatcher.new(5) < 4
85
88
  end
86
89
 
87
90
  it "does not raise an exception when expected < actual returns true" do
88
- PositiveOperatorMatcher.new(4) < 5
91
+ SpecPositiveOperatorMatcher.new(4) < 5
89
92
  end
90
93
  end
91
94
 
92
- describe PositiveOperatorMatcher, "<= operater" do
93
- it "raises an ExpectationNotMetError when expected < actual returns false" do
95
+ describe SpecPositiveOperatorMatcher, "<= operater" do
96
+ it "raises an SpecExpectationNotMetError when expected < actual returns false" do
94
97
  lambda {
95
- PositiveOperatorMatcher.new(5) <= 4
96
- }.should raise_error(ExpectationNotMetError)
98
+ SpecPositiveOperatorMatcher.new(5) <= 4
99
+ }.should raise_error(SpecExpectationNotMetError)
97
100
  end
98
101
 
99
102
  it "provides a failure message that 'Expected x to be less than or equal to y'" do
100
- Expectation.should_receive(:fail_with).with("Expected 5\n", "to be less than or equal to 4\n")
101
- PositiveOperatorMatcher.new(5) <= 4
103
+ SpecExpectation.should_receive(:fail_with).with(
104
+ "Expected 5\n", "to be less than or equal to 4\n")
105
+ SpecPositiveOperatorMatcher.new(5) <= 4
102
106
  end
103
107
 
104
108
  it "does not raise an exception when expected < actual returns true" do
105
- PositiveOperatorMatcher.new(4) <= 5
106
- PositiveOperatorMatcher.new(4) <= 4
109
+ SpecPositiveOperatorMatcher.new(4) <= 5
110
+ SpecPositiveOperatorMatcher.new(4) <= 4
107
111
  end
108
112
  end
109
113
 
110
- describe NegativeOperatorMatcher, "== operator" do
111
- it "raises an ExpectationNotMetError when expected == actual returns true" do
114
+ describe SpecNegativeOperatorMatcher, "== operator" do
115
+ it "raises an SpecExpectationNotMetError when expected == actual returns true" do
112
116
  lambda {
113
- NegativeOperatorMatcher.new(1) == 1
114
- }.should raise_error(ExpectationNotMetError)
117
+ SpecNegativeOperatorMatcher.new(1) == 1
118
+ }.should raise_error(SpecExpectationNotMetError)
115
119
  end
116
120
 
117
121
  it "provides a failure message that 'Expected x not to equal y'" do
118
- Expectation.should_receive(:fail_with).with("Expected 1\n", "not to equal 1\n")
119
- NegativeOperatorMatcher.new(1) == 1
122
+ SpecExpectation.should_receive(:fail_with).with("Expected 1\n", "not to equal 1\n")
123
+ SpecNegativeOperatorMatcher.new(1) == 1
120
124
  end
121
125
 
122
126
  it "does not raise an exception when expected == actual returns false" do
123
- NegativeOperatorMatcher.new(1) == 2
127
+ SpecNegativeOperatorMatcher.new(1) == 2
124
128
  end
125
129
  end
126
130
 
127
- describe NegativeOperatorMatcher, "=~ operator" do
128
- it "raises an ExpectationNotMetError when expected =~ actual returns true" do
131
+ describe SpecNegativeOperatorMatcher, "=~ operator" do
132
+ it "raises an SpecExpectationNotMetError when expected =~ actual returns true" do
129
133
  lambda {
130
- NegativeOperatorMatcher.new('real') =~ /real/
131
- }.should raise_error(ExpectationNotMetError)
134
+ SpecNegativeOperatorMatcher.new('real') =~ /real/
135
+ }.should raise_error(SpecExpectationNotMetError)
132
136
  end
133
137
 
134
138
  it "provides a failure message that 'Expected \"x\" not to match /y/'" do
135
- Expectation.should_receive(:fail_with).with("Expected \"real\"\n", "not to match /real/\n")
136
- NegativeOperatorMatcher.new('real') =~ /real/
139
+ SpecExpectation.should_receive(:fail_with).with(
140
+ "Expected \"real\"\n", "not to match /real/\n")
141
+ SpecNegativeOperatorMatcher.new('real') =~ /real/
137
142
  end
138
143
 
139
144
  it "does not raise an exception when expected =~ actual returns false" do
140
- NegativeOperatorMatcher.new('real') =~ /fake/
145
+ SpecNegativeOperatorMatcher.new('real') =~ /fake/
141
146
  end
142
147
  end
143
148
 
144
- describe NegativeOperatorMatcher, "< operator" do
145
- it "raises an ExpectationNotMetError when expected < actual returns true" do
149
+ describe SpecNegativeOperatorMatcher, "< operator" do
150
+ it "raises an SpecExpectationNotMetError when expected < actual returns true" do
146
151
  lambda {
147
- NegativeOperatorMatcher.new(4) < 5
148
- }.should raise_error(ExpectationNotMetError)
152
+ SpecNegativeOperatorMatcher.new(4) < 5
153
+ }.should raise_error(SpecExpectationNotMetError)
149
154
  end
150
155
 
151
156
  it "provides a failure message that 'Expected x not to be less than y'" do
152
- Expectation.should_receive(:fail_with).with("Expected 4\n", "not to be less than 5\n")
153
- NegativeOperatorMatcher.new(4) < 5
157
+ SpecExpectation.should_receive(:fail_with).with(
158
+ "Expected 4\n", "not to be less than 5\n")
159
+ SpecNegativeOperatorMatcher.new(4) < 5
154
160
  end
155
161
 
156
162
  it "does not raise an exception when expected < actual returns false" do
157
- NegativeOperatorMatcher.new(5) < 4
163
+ SpecNegativeOperatorMatcher.new(5) < 4
158
164
  end
159
165
  end
160
166
 
161
- describe NegativeOperatorMatcher, "<= operator" do
162
- it "raises an ExpectationNotMetError when expected <= actual returns true" do
167
+ describe SpecNegativeOperatorMatcher, "<= operator" do
168
+ it "raises an SpecExpectationNotMetError when expected <= actual returns true" do
163
169
  lambda {
164
- NegativeOperatorMatcher.new(4) <= 5
165
- }.should raise_error(ExpectationNotMetError)
170
+ SpecNegativeOperatorMatcher.new(4) <= 5
171
+ }.should raise_error(SpecExpectationNotMetError)
166
172
  lambda {
167
- NegativeOperatorMatcher.new(5) <= 5
168
- }.should raise_error(ExpectationNotMetError)
173
+ SpecNegativeOperatorMatcher.new(5) <= 5
174
+ }.should raise_error(SpecExpectationNotMetError)
169
175
  end
170
176
 
171
177
  it "provides a failure message that 'Expected x not to be less than or equal to y'" do
172
- Expectation.should_receive(:fail_with).with("Expected 4\n", "not to be less than or equal to 5\n")
173
- NegativeOperatorMatcher.new(4) <= 5
178
+ SpecExpectation.should_receive(:fail_with).with(
179
+ "Expected 4\n", "not to be less than or equal to 5\n")
180
+ SpecNegativeOperatorMatcher.new(4) <= 5
174
181
  end
175
182
 
176
183
  it "does not raise an exception when expected <= actual returns false" do
177
- NegativeOperatorMatcher.new(5) <= 4
184
+ SpecNegativeOperatorMatcher.new(5) <= 4
178
185
  end
179
186
  end
180
187
 
181
- describe NegativeOperatorMatcher, "> operator" do
182
- it "raises an ExpectationNotMetError when expected > actual returns true" do
188
+ describe SpecNegativeOperatorMatcher, "> operator" do
189
+ it "raises an SpecExpectationNotMetError when expected > actual returns true" do
183
190
  lambda {
184
- NegativeOperatorMatcher.new(5) > 4
185
- }.should raise_error(ExpectationNotMetError)
191
+ SpecNegativeOperatorMatcher.new(5) > 4
192
+ }.should raise_error(SpecExpectationNotMetError)
186
193
  end
187
194
 
188
195
  it "provides a failure message that 'Expected x not to be greater than y'" do
189
- Expectation.should_receive(:fail_with).with("Expected 5\n", "not to be greater than 4\n")
190
- NegativeOperatorMatcher.new(5) > 4
196
+ SpecExpectation.should_receive(:fail_with).with(
197
+ "Expected 5\n", "not to be greater than 4\n")
198
+ SpecNegativeOperatorMatcher.new(5) > 4
191
199
  end
192
200
 
193
201
  it "does not raise an exception when expected > actual returns false" do
194
- NegativeOperatorMatcher.new(4) > 5
202
+ SpecNegativeOperatorMatcher.new(4) > 5
195
203
  end
196
204
  end
197
205
 
198
- describe NegativeOperatorMatcher, ">= operator" do
199
- it "raises an ExpectationNotMetError when expected >= actual returns true" do
206
+ describe SpecNegativeOperatorMatcher, ">= operator" do
207
+ it "raises an SpecExpectationNotMetError when expected >= actual returns true" do
200
208
  lambda {
201
- NegativeOperatorMatcher.new(5) >= 4
202
- }.should raise_error(ExpectationNotMetError)
209
+ SpecNegativeOperatorMatcher.new(5) >= 4
210
+ }.should raise_error(SpecExpectationNotMetError)
203
211
  lambda {
204
- NegativeOperatorMatcher.new(5) >= 5
205
- }.should raise_error(ExpectationNotMetError)
212
+ SpecNegativeOperatorMatcher.new(5) >= 5
213
+ }.should raise_error(SpecExpectationNotMetError)
206
214
  end
207
215
 
208
216
  it "provides a failure message that 'Expected x not to be greater than or equal to y'" do
209
- Expectation.should_receive(:fail_with).with("Expected 5\n", "not to be greater than or equal to 4\n")
210
- NegativeOperatorMatcher.new(5) >= 4
217
+ SpecExpectation.should_receive(:fail_with).with(
218
+ "Expected 5\n", "not to be greater than or equal to 4\n")
219
+ SpecNegativeOperatorMatcher.new(5) >= 4
211
220
  end
212
221
 
213
222
  it "does not raise an exception when expected >= actual returns false" do
214
- NegativeOperatorMatcher.new(4) >= 5
223
+ SpecNegativeOperatorMatcher.new(4) >= 5
215
224
  end
216
225
  end