mspec 1.5.10 → 1.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/mspec/commands/mkspec.rb +1 -1
- data/lib/mspec/expectations/expectations.rb +4 -4
- data/lib/mspec/expectations/should.rb +4 -4
- data/lib/mspec/guards/endian.rb +5 -8
- data/lib/mspec/guards/guard.rb +1 -1
- data/lib/mspec/helpers/const_lookup.rb +2 -1
- data/lib/mspec/helpers/flunk.rb +1 -1
- data/lib/mspec/helpers/io.rb +2 -2
- data/lib/mspec/helpers/ruby_exe.rb +6 -3
- data/lib/mspec/matchers/base.rb +14 -14
- data/lib/mspec/matchers/be_an_instance_of.rb +26 -0
- data/lib/mspec/mocks/mock.rb +5 -5
- data/lib/mspec/runner/context.rb +1 -1
- data/lib/mspec/runner/exception.rb +3 -3
- data/lib/mspec/runner/formatters/dotted.rb +2 -2
- data/lib/mspec/utils/name_map.rb +2 -1
- data/lib/mspec/utils/options.rb +3 -1
- data/lib/mspec/utils/script.rb +3 -2
- data/lib/mspec/version.rb +1 -1
- data/spec/commands/mkspec_spec.rb +2 -1
- data/spec/expectations/expectations_spec.rb +10 -10
- data/spec/expectations/should.rb +71 -0
- data/spec/expectations/should_spec.rb +58 -126
- data/spec/guards/endian_spec.rb +6 -6
- data/spec/helpers/flunk_spec.rb +3 -3
- data/spec/matchers/base_spec.rb +99 -90
- data/spec/matchers/be_an_instance_of_spec.rb +50 -0
- data/spec/matchers/be_close_spec.rb +2 -2
- data/spec/matchers/be_kind_of_spec.rb +5 -3
- data/spec/matchers/equal_utf16_spec.rb +12 -2
- data/spec/matchers/respond_to_spec.rb +5 -3
- data/spec/mocks/mock_spec.rb +22 -21
- data/spec/runner/actions/tally_spec.rb +2 -2
- data/spec/runner/actions/timer_spec.rb +4 -4
- data/spec/runner/context_spec.rb +4 -4
- data/spec/runner/exception_spec.rb +10 -10
- data/spec/runner/formatters/dotted_spec.rb +6 -6
- data/spec/runner/formatters/file_spec.rb +3 -3
- data/spec/runner/formatters/html_spec.rb +3 -3
- data/spec/runner/formatters/method_spec.rb +2 -2
- data/spec/runner/formatters/specdoc_spec.rb +5 -5
- data/spec/runner/formatters/summary_spec.rb +1 -1
- data/spec/utils/options_spec.rb +10 -9
- data/spec/utils/script_spec.rb +7 -6
- 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 '
|
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
|
-
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
|
data/spec/guards/endian_spec.rb
CHANGED
@@ -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([
|
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([
|
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([
|
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([
|
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([
|
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([
|
62
|
+
@guard.stub!(:pattern).and_return([?\000])
|
63
63
|
@guard.should_receive(:unregister)
|
64
64
|
lambda do
|
65
65
|
little_endian { raise Exception }
|
data/spec/helpers/flunk_spec.rb
CHANGED
@@ -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
|
13
|
-
lambda { flunk }.should raise_error(
|
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(
|
17
|
+
lambda {flunk "test"}.should raise_error(SpecExpectationNotMetError)
|
18
18
|
end
|
19
19
|
end
|
data/spec/matchers/base_spec.rb
CHANGED
@@ -3,214 +3,223 @@ require 'mspec/expectations/expectations'
|
|
3
3
|
require 'mspec/matchers/base'
|
4
4
|
require 'time'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "raises an
|
6
|
+
describe SpecPositiveOperatorMatcher, "== operator" do
|
7
|
+
it "raises an SpecExpectationNotMetError when expected == actual returns false" do
|
8
8
|
lambda {
|
9
|
-
|
10
|
-
}.should raise_error(
|
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
|
-
|
15
|
-
|
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
|
-
|
19
|
+
SpecPositiveOperatorMatcher.new(1) == 1
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it "raises an
|
23
|
+
describe SpecPositiveOperatorMatcher, "=~ operator" do
|
24
|
+
it "raises an SpecExpectationNotMetError when expected =~ actual returns false" do
|
25
25
|
lambda {
|
26
|
-
|
27
|
-
}.should raise_error(
|
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
|
-
|
32
|
-
|
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
|
-
|
37
|
+
SpecPositiveOperatorMatcher.new('real') =~ /real/
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
describe
|
41
|
-
it "raises an
|
41
|
+
describe SpecPositiveOperatorMatcher, "> operator" do
|
42
|
+
it "raises an SpecExpectationNotMetError when expected > actual returns false" do
|
42
43
|
lambda {
|
43
|
-
|
44
|
-
}.should raise_error(
|
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
|
-
|
49
|
-
|
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
|
-
|
55
|
+
SpecPositiveOperatorMatcher.new(5) > 4
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
57
|
-
describe
|
58
|
-
it "raises an
|
59
|
+
describe SpecPositiveOperatorMatcher, ">= operator" do
|
60
|
+
it "raises an SpecExpectationNotMetError when expected >= actual returns false" do
|
59
61
|
lambda {
|
60
|
-
|
61
|
-
}.should raise_error(
|
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
|
-
|
66
|
-
|
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
|
-
|
71
|
-
|
73
|
+
SpecPositiveOperatorMatcher.new(5) >= 4
|
74
|
+
SpecPositiveOperatorMatcher.new(5) >= 5
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
75
|
-
describe
|
76
|
-
it "raises an
|
78
|
+
describe SpecPositiveOperatorMatcher, "< operater" do
|
79
|
+
it "raises an SpecExpectationNotMetError when expected < actual returns false" do
|
77
80
|
lambda {
|
78
|
-
|
79
|
-
}.should raise_error(
|
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
|
-
|
84
|
-
|
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
|
-
|
91
|
+
SpecPositiveOperatorMatcher.new(4) < 5
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
92
|
-
describe
|
93
|
-
it "raises an
|
95
|
+
describe SpecPositiveOperatorMatcher, "<= operater" do
|
96
|
+
it "raises an SpecExpectationNotMetError when expected < actual returns false" do
|
94
97
|
lambda {
|
95
|
-
|
96
|
-
}.should raise_error(
|
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
|
-
|
101
|
-
|
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
|
-
|
106
|
-
|
109
|
+
SpecPositiveOperatorMatcher.new(4) <= 5
|
110
|
+
SpecPositiveOperatorMatcher.new(4) <= 4
|
107
111
|
end
|
108
112
|
end
|
109
113
|
|
110
|
-
describe
|
111
|
-
it "raises an
|
114
|
+
describe SpecNegativeOperatorMatcher, "== operator" do
|
115
|
+
it "raises an SpecExpectationNotMetError when expected == actual returns true" do
|
112
116
|
lambda {
|
113
|
-
|
114
|
-
}.should raise_error(
|
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
|
-
|
119
|
-
|
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
|
-
|
127
|
+
SpecNegativeOperatorMatcher.new(1) == 2
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
127
|
-
describe
|
128
|
-
it "raises an
|
131
|
+
describe SpecNegativeOperatorMatcher, "=~ operator" do
|
132
|
+
it "raises an SpecExpectationNotMetError when expected =~ actual returns true" do
|
129
133
|
lambda {
|
130
|
-
|
131
|
-
}.should raise_error(
|
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
|
-
|
136
|
-
|
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
|
-
|
145
|
+
SpecNegativeOperatorMatcher.new('real') =~ /fake/
|
141
146
|
end
|
142
147
|
end
|
143
148
|
|
144
|
-
describe
|
145
|
-
it "raises an
|
149
|
+
describe SpecNegativeOperatorMatcher, "< operator" do
|
150
|
+
it "raises an SpecExpectationNotMetError when expected < actual returns true" do
|
146
151
|
lambda {
|
147
|
-
|
148
|
-
}.should raise_error(
|
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
|
-
|
153
|
-
|
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
|
-
|
163
|
+
SpecNegativeOperatorMatcher.new(5) < 4
|
158
164
|
end
|
159
165
|
end
|
160
166
|
|
161
|
-
describe
|
162
|
-
it "raises an
|
167
|
+
describe SpecNegativeOperatorMatcher, "<= operator" do
|
168
|
+
it "raises an SpecExpectationNotMetError when expected <= actual returns true" do
|
163
169
|
lambda {
|
164
|
-
|
165
|
-
}.should raise_error(
|
170
|
+
SpecNegativeOperatorMatcher.new(4) <= 5
|
171
|
+
}.should raise_error(SpecExpectationNotMetError)
|
166
172
|
lambda {
|
167
|
-
|
168
|
-
}.should raise_error(
|
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
|
-
|
173
|
-
|
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
|
-
|
184
|
+
SpecNegativeOperatorMatcher.new(5) <= 4
|
178
185
|
end
|
179
186
|
end
|
180
187
|
|
181
|
-
describe
|
182
|
-
it "raises an
|
188
|
+
describe SpecNegativeOperatorMatcher, "> operator" do
|
189
|
+
it "raises an SpecExpectationNotMetError when expected > actual returns true" do
|
183
190
|
lambda {
|
184
|
-
|
185
|
-
}.should raise_error(
|
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
|
-
|
190
|
-
|
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
|
-
|
202
|
+
SpecNegativeOperatorMatcher.new(4) > 5
|
195
203
|
end
|
196
204
|
end
|
197
205
|
|
198
|
-
describe
|
199
|
-
it "raises an
|
206
|
+
describe SpecNegativeOperatorMatcher, ">= operator" do
|
207
|
+
it "raises an SpecExpectationNotMetError when expected >= actual returns true" do
|
200
208
|
lambda {
|
201
|
-
|
202
|
-
}.should raise_error(
|
209
|
+
SpecNegativeOperatorMatcher.new(5) >= 4
|
210
|
+
}.should raise_error(SpecExpectationNotMetError)
|
203
211
|
lambda {
|
204
|
-
|
205
|
-
}.should raise_error(
|
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
|
-
|
210
|
-
|
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
|
-
|
223
|
+
SpecNegativeOperatorMatcher.new(4) >= 5
|
215
224
|
end
|
216
225
|
end
|