jeremymcanally-matchy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +22 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +68 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/lib/matchy.rb +16 -0
- data/lib/matchy/built_in/enumerable_expectations.rb +69 -0
- data/lib/matchy/built_in/error_expectations.rb +80 -0
- data/lib/matchy/built_in/operator_expectations.rb +97 -0
- data/lib/matchy/built_in/truth_expectations.rb +181 -0
- data/lib/matchy/expectation.rb +47 -0
- data/lib/matchy/modals.rb +46 -0
- data/lib/matchy/version.rb +9 -0
- data/matchy.gemspec +47 -0
- data/setup.rb +1585 -0
- data/test/test_enumerable_expectations.rb +91 -0
- data/test/test_error_expectations.rb +109 -0
- data/test/test_expectation_base.rb +35 -0
- data/test/test_modals.rb +27 -0
- data/test/test_operator_expectations.rb +159 -0
- data/test/test_truth_expectations.rb +217 -0
- metadata +79 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestEnumerableExpectations < Test::Unit::TestCase
|
4
|
+
def test_include
|
5
|
+
[1,2,3,4].should include(4)
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_include_fail
|
9
|
+
lambda {
|
10
|
+
[1,2,3,4].should include(6)
|
11
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_exclude
|
15
|
+
[1,2,3,4].should exclude(9)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_exclude_fail
|
19
|
+
lambda {
|
20
|
+
[1,2,3,4].should exclude(4)
|
21
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_multi_include
|
25
|
+
[1,2,3,4].should include(1,2)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_multi_include_fail
|
29
|
+
lambda {
|
30
|
+
[1,2,3,4].should include(6,7,8)
|
31
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_multi_exclude
|
35
|
+
[1,2,3,4].should exclude(13,14)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_multi_exclude_fail
|
39
|
+
lambda {
|
40
|
+
[1,2,3,4].should exclude(2,3,4)
|
41
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_negative_include
|
45
|
+
[1,2,3,4].should_not include(9)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_negative_include_fail
|
49
|
+
lambda {
|
50
|
+
[1,2,3,4].should_not include(4)
|
51
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_negative_exclude
|
55
|
+
[1,2,3,4].should_not exclude(3)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_negative_exclude_fail
|
59
|
+
lambda {
|
60
|
+
[1,2,3,4].should_not exclude(6,7)
|
61
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_include_fail_message
|
65
|
+
obj = include(1)
|
66
|
+
obj.matches?([4,5,6])
|
67
|
+
|
68
|
+
obj.failure_message.should be "Expected [4, 5, 6] to include [1]."
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_include_negative_fail_message
|
72
|
+
obj = include(1)
|
73
|
+
obj.matches?([4,5,6])
|
74
|
+
|
75
|
+
obj.negative_failure_message.should be "Expected [4, 5, 6] to not include [1]."
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_exclude_fail_message
|
79
|
+
obj = exclude(4)
|
80
|
+
obj.matches?([4,5,6])
|
81
|
+
|
82
|
+
obj.failure_message.should be "Expected [4, 5, 6] to exclude [4]."
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_exclude_negative_fail_message
|
86
|
+
obj = exclude(4)
|
87
|
+
obj.matches?([4,5,6])
|
88
|
+
|
89
|
+
obj.negative_failure_message.should be "Expected [4, 5, 6] to not exclude [4]."
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestErrorExpectations < Test::Unit::TestCase
|
4
|
+
def test_raises_error
|
5
|
+
lambda { raise "FAIL" }.should raise_error
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_raises_error_fail
|
9
|
+
lambda {
|
10
|
+
lambda { "WIN" }.should raise_error
|
11
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_negative_raises_error
|
15
|
+
lambda { "WIN" }.should_not raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_negative_raises_error_fail
|
19
|
+
lambda {
|
20
|
+
lambda { raise "FAIL" }.should_not raise_error
|
21
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_raises_specific_error
|
25
|
+
lambda { raise TypeError }.should raise_error(TypeError)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_raises_specific_error_fail_with_no_error
|
29
|
+
lambda {
|
30
|
+
lambda { "WIN" }.should raise_error(TypeError)
|
31
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_raises_specific_error_fail_with_different_error
|
35
|
+
lambda {
|
36
|
+
lambda { raise StandardError }.should raise_error(TypeError)
|
37
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_throws_symbol
|
41
|
+
lambda {
|
42
|
+
throw :win
|
43
|
+
}.should throw_symbol(:win)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_throws_symbol_fails_with_different_symbol
|
47
|
+
lambda {
|
48
|
+
lambda {
|
49
|
+
throw :fail
|
50
|
+
}.should throw_symbol(:win)
|
51
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_negative_throws_symbol
|
55
|
+
lambda {
|
56
|
+
"not this time!"
|
57
|
+
}.should_not throw_symbol(:win)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_negative_throws_symbol_fails_with_different_symbol
|
61
|
+
lambda{
|
62
|
+
lambda {
|
63
|
+
throw :fail
|
64
|
+
}.should_not throw_symbol(:fail)
|
65
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_error_fail_message
|
69
|
+
obj = raise_error(TypeError)
|
70
|
+
obj.matches?(lambda { raise NameError })
|
71
|
+
|
72
|
+
obj.failure_message.should =~ /Expected #<(.*)> to raise TypeError, but NameError was raised instead./
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_error_fail_message_when_no_error
|
76
|
+
obj = raise_error(TypeError)
|
77
|
+
obj.matches?(lambda { "moop" })
|
78
|
+
|
79
|
+
obj.failure_message.should =~ /Expected #<(.*)> to raise TypeError, but none was raised./
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_error_negative_fail_message
|
83
|
+
obj = raise_error(TypeError)
|
84
|
+
obj.matches?(lambda { raise TypeError })
|
85
|
+
|
86
|
+
obj.negative_failure_message.should =~ /Expected #<(.*)> to not raise TypeError./
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_throw_fail_message
|
90
|
+
obj = throw_symbol(:fail)
|
91
|
+
obj.matches?(lambda { throw :lame })
|
92
|
+
|
93
|
+
obj.failure_message.should =~ /Expected #<(.*)> to throw :fail, but :lame was thrown instead./
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_throw_fail_message_when_no_symbol
|
97
|
+
obj = throw_symbol(:fail)
|
98
|
+
obj.matches?(lambda { "moop" })
|
99
|
+
|
100
|
+
obj.failure_message.should =~ /Expected #<(.*)> to throw :fail, but no symbol was thrown./
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_throw_negative_fail_message
|
104
|
+
obj = throw_symbol(:fail)
|
105
|
+
obj.matches?(lambda { throw :fail })
|
106
|
+
|
107
|
+
obj.negative_failure_message.should =~ /Expected #<(.*)> to not throw :fail./
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestExpectationBase < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@instance = Matchy::Expectations::Base.new(true, self)
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_ivars
|
9
|
+
@instance.instance_variable_get("@expected").should eql(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_matches_throws_error
|
13
|
+
lambda {
|
14
|
+
@instance.matches?(true)
|
15
|
+
}.should raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_fail_should_raise
|
19
|
+
lambda {
|
20
|
+
@instance.fail!(false)
|
21
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_pass
|
25
|
+
@instance.pass!(true)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_failure_message
|
29
|
+
@instance.failure_message.should eql("OMG FAIL.")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_negative_failure_message
|
33
|
+
@instance.negative_failure_message.should eql("OMG FAIL TO FAIL.")
|
34
|
+
end
|
35
|
+
end
|
data/test/test_modals.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestModals < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@expectation = Matchy::Expectations::EqlExpectation.new(3, self)
|
6
|
+
@bad_expectation = Matchy::Expectations::EqlExpectation.new(4, self)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_should
|
10
|
+
3.should(@expectation)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_not
|
14
|
+
3.should_not(@bad_expectation)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_operator_expectation_returned
|
18
|
+
obj = 3.should
|
19
|
+
assert_equal Matchy::Expectations::OperatorExpectation, obj.class
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def test_should_not_operator_expectation_returned
|
24
|
+
obj = 3.should_not
|
25
|
+
assert_equal Matchy::Expectations::OperatorExpectation, obj.class
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestOperatorExpectations < Test::Unit::TestCase
|
4
|
+
# EQUALS (==)
|
5
|
+
def test_equals
|
6
|
+
3.should == 3
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_equals_fails
|
10
|
+
lambda {
|
11
|
+
3.should == 5
|
12
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_negative_equals
|
16
|
+
3.should_not == 4
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_negative_equals_fails
|
20
|
+
lambda {
|
21
|
+
3.should_not == 3
|
22
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
23
|
+
end
|
24
|
+
|
25
|
+
# LESS THAN (<)
|
26
|
+
def test_less_than
|
27
|
+
3.should < 5
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_less_than_fails
|
31
|
+
lambda {
|
32
|
+
4.should < 3
|
33
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_less_than_equals
|
37
|
+
3.should_not < 2
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_negative_less_than_fails
|
41
|
+
lambda {
|
42
|
+
4.should_not < 5
|
43
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
44
|
+
end
|
45
|
+
|
46
|
+
# GREATER THAN (<)
|
47
|
+
def test_greater_than
|
48
|
+
3.should > 2
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_greater_than_fails
|
52
|
+
lambda {
|
53
|
+
4.should > 5
|
54
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_greater_than_equals
|
58
|
+
3.should_not > 5
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_negative_greater_than_fails
|
62
|
+
lambda {
|
63
|
+
4.should_not > 3
|
64
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
65
|
+
end
|
66
|
+
|
67
|
+
# LESS THAN EQUAL (<=)
|
68
|
+
def test_less_than_equal
|
69
|
+
3.should <= 5
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_less_than_equal_equal
|
73
|
+
3.should <= 3
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_less_than_equal_fails
|
77
|
+
lambda {
|
78
|
+
4.should <= 3
|
79
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_negative_less_than_equal
|
83
|
+
3.should_not <= 2
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_negative_less_than_equal_fails
|
87
|
+
lambda {
|
88
|
+
4.should_not <= 5
|
89
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
90
|
+
end
|
91
|
+
|
92
|
+
# GREATER THAN EQUALS (<=)
|
93
|
+
def test_greater_than_equal
|
94
|
+
3.should >= 2
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_greater_than_equal_equals
|
98
|
+
3.should >= 3
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_greater_than_equal_fails
|
102
|
+
lambda {
|
103
|
+
4.should >= 5
|
104
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_negative_greater_than_equal_equals
|
108
|
+
3.should_not >= 5
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_negative_greater_than_equal_fails
|
112
|
+
lambda {
|
113
|
+
4.should_not >= 3
|
114
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
115
|
+
end
|
116
|
+
|
117
|
+
# MATCHES (=~)
|
118
|
+
def test_matches
|
119
|
+
"hey world".should =~ /world/
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_matches_fails
|
123
|
+
lambda {
|
124
|
+
"d00d ur 1337".should =~ /world/
|
125
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_negative_matches
|
129
|
+
"1337@age".should_not =~ /434/
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_negative_matches_fails
|
133
|
+
lambda {
|
134
|
+
"it's a freak out!".should_not =~ /freak/
|
135
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_fail_message
|
139
|
+
obj = Matchy::Expectations::OperatorExpectation.new(3, true)
|
140
|
+
|
141
|
+
def obj.fail!(fail)
|
142
|
+
end
|
143
|
+
|
144
|
+
obj == 4
|
145
|
+
|
146
|
+
obj.send(:failure_message, "==").should =~ /Expected 3 to == 4./
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_negative_fail_message
|
150
|
+
obj = Matchy::Expectations::OperatorExpectation.new(3, true)
|
151
|
+
|
152
|
+
def obj.fail!(fail)
|
153
|
+
end
|
154
|
+
|
155
|
+
obj == 3
|
156
|
+
|
157
|
+
obj.send(:negative_failure_message, "==").should =~ /Expected 3 to not == 3./
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class Exister
|
4
|
+
def initialize(what)
|
5
|
+
@what = what
|
6
|
+
end
|
7
|
+
|
8
|
+
def exist?
|
9
|
+
@what
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestTruthExpectations < Test::Unit::TestCase
|
14
|
+
def test_equal
|
15
|
+
3.should equal(3)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_negative_equal
|
19
|
+
instance = String.new
|
20
|
+
|
21
|
+
instance.should_not equal(String.new)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_equal_fail
|
25
|
+
lambda {
|
26
|
+
3.should equal(4)
|
27
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_negative_equal_fail
|
31
|
+
lambda {
|
32
|
+
3.should_not equal(3)
|
33
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_eql
|
37
|
+
3.should eql(3)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_negative_eql
|
41
|
+
3.should_not eql(9)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_eql_fail
|
45
|
+
lambda {
|
46
|
+
3.should eql(13)
|
47
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_negative_eql_fail
|
51
|
+
lambda {
|
52
|
+
3.should_not eql(3)
|
53
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_exists
|
57
|
+
thing = Exister.new(true)
|
58
|
+
thing.should exist
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_negative_exists
|
62
|
+
thing = Exister.new(false)
|
63
|
+
thing.should_not exist
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_exists_fail
|
67
|
+
lambda {
|
68
|
+
thing = Exister.new(false)
|
69
|
+
thing.should exist
|
70
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_negative_exists_fail
|
74
|
+
lambda {
|
75
|
+
thing = Exister.new(true)
|
76
|
+
thing.should_not exist
|
77
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_be
|
81
|
+
true.should be(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_negative_be
|
85
|
+
true.should_not be(false)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_be_fail
|
89
|
+
lambda {
|
90
|
+
true.should be(false)
|
91
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_be_close
|
95
|
+
(5.0 - 2.0).should be_close(3.0)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_be_close_with_delta
|
99
|
+
(5.0 - 2.0).should be_close(3.0, 0.2)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_be_close_fail
|
103
|
+
lambda {
|
104
|
+
(19.0 - 13.0).should be_close(33.04)
|
105
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_be_close_with_delta_fail
|
109
|
+
lambda {
|
110
|
+
(19.0 - 13.0).should be_close(6.0, 0.0)
|
111
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_satisfy
|
115
|
+
13.should satisfy(lambda {|i| i < 15})
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_negative_satisfy
|
119
|
+
13.should_not satisfy(lambda {|i| i < 10})
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_satisfy_fail
|
123
|
+
lambda {
|
124
|
+
13.should satisfy(lambda {|i| i > 15})
|
125
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_negative_satisfy_fail
|
129
|
+
lambda {
|
130
|
+
13.should_not satisfy(lambda {|i| i < 15})
|
131
|
+
}.should raise_error(Test::Unit::AssertionFailedError)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_equal_fail_message
|
135
|
+
obj = equal(4)
|
136
|
+
obj.matches?(5)
|
137
|
+
|
138
|
+
obj.failure_message.should be "Expected 5 to equal 4."
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_equal_negative_fail_message
|
142
|
+
obj = equal(5)
|
143
|
+
obj.matches?(5)
|
144
|
+
|
145
|
+
obj.negative_failure_message.should be "Expected 5 to not equal 5."
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_eql_fail_message
|
149
|
+
obj = eql(4)
|
150
|
+
obj.matches?(5)
|
151
|
+
|
152
|
+
obj.failure_message.should be "Expected 5 to eql 4."
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_eql_negative_fail_message
|
156
|
+
obj = eql(5)
|
157
|
+
obj.matches?(5)
|
158
|
+
|
159
|
+
obj.negative_failure_message.should be "Expected 5 to not eql 5."
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_exist_fail_message
|
163
|
+
obj = exist
|
164
|
+
obj.matches?(Exister.new(false))
|
165
|
+
|
166
|
+
obj.failure_message.should =~ /Expected #<(.*)> to exist./
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_exist_negative_fail_message
|
170
|
+
obj = exist
|
171
|
+
obj.matches?(Exister.new(true))
|
172
|
+
|
173
|
+
obj.negative_failure_message.should =~ /Expected #<(.*)> to not exist./
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_be_close_fail_message
|
177
|
+
obj = be_close(3.0)
|
178
|
+
obj.matches?(6.0)
|
179
|
+
|
180
|
+
obj.failure_message.should be "Expected 6.0 to be close to 3.0 (delta: 0.3)."
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_be_close_negative_fail_message
|
184
|
+
obj = be_close(5.0)
|
185
|
+
obj.matches?(5.0)
|
186
|
+
|
187
|
+
obj.negative_failure_message.should be "Expected 5.0 to not be close to 5.0 (delta: 0.3)."
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_be_fail_message
|
191
|
+
obj = be(4)
|
192
|
+
obj.matches?(5)
|
193
|
+
|
194
|
+
obj.failure_message.should be "Expected 5 to be 4."
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_be_negative_fail_message
|
198
|
+
obj = be(5)
|
199
|
+
obj.matches?(5)
|
200
|
+
|
201
|
+
obj.negative_failure_message.should be "Expected 5 to not be 5."
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_satisfy_fail_message
|
205
|
+
obj = satisfy(lambda {|x| x == 4})
|
206
|
+
obj.matches?(6)
|
207
|
+
|
208
|
+
obj.failure_message.should be "Expected 6 to satisfy given block."
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_eql_negative_fail_message
|
212
|
+
obj = satisfy(lambda {|x| x == 4})
|
213
|
+
obj.matches?(4)
|
214
|
+
|
215
|
+
obj.negative_failure_message.should be "Expected 4 to not satisfy given block."
|
216
|
+
end
|
217
|
+
end
|