rspec-expectations 2.0.0.beta.19 → 2.0.0.beta.20
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Rakefile +0 -7
- data/VERSION +1 -1
- data/features/matchers/define_matcher.feature +40 -4
- data/lib/rspec/expectations/extensions.rb +1 -0
- data/lib/rspec/expectations/extensions/array.rb +7 -0
- data/lib/rspec/matchers/dsl.rb +4 -0
- data/lib/rspec/matchers/throw_symbol.rb +2 -2
- data/rspec-expectations.gemspec +10 -15
- data/spec/rspec/expectations/differ_spec.rb +3 -3
- data/spec/rspec/expectations/handler_spec.rb +2 -2
- data/spec/rspec/matchers/be_spec.rb +68 -68
- data/spec/rspec/matchers/change_spec.rb +43 -43
- data/spec/rspec/matchers/description_generation_spec.rb +1 -1
- data/spec/rspec/matchers/eql_spec.rb +5 -5
- data/spec/rspec/matchers/equal_spec.rb +5 -5
- data/spec/rspec/matchers/exist_spec.rb +1 -1
- data/spec/rspec/matchers/has_spec.rb +11 -11
- data/spec/rspec/matchers/have_spec.rb +39 -39
- data/spec/rspec/matchers/include_spec.rb +14 -14
- data/spec/rspec/matchers/match_array_spec.rb +10 -10
- data/spec/rspec/matchers/match_spec.rb +10 -10
- data/spec/rspec/matchers/operator_matcher_spec.rb +24 -24
- data/spec/rspec/matchers/raise_error_spec.rb +46 -46
- data/spec/rspec/matchers/satisfy_spec.rb +4 -4
- data/spec/rspec/matchers/throw_symbol_spec.rb +25 -25
- metadata +28 -40
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -24,13 +24,6 @@ begin
|
|
24
24
|
gem.add_development_dependency('aruba', ">= 0.1.1")
|
25
25
|
gem.add_development_dependency('rspec-core', ">= #{RSpec::Expectations::Version::STRING}")
|
26
26
|
gem.add_development_dependency('rspec-mocks', ">= #{RSpec::Expectations::Version::STRING}")
|
27
|
-
gem.post_install_message = <<-EOM
|
28
|
-
#{"*"*50}
|
29
|
-
|
30
|
-
Thank you for installing #{gem.summary}
|
31
|
-
|
32
|
-
#{"*"*50}
|
33
|
-
EOM
|
34
27
|
end
|
35
28
|
rescue LoadError
|
36
29
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.20
|
@@ -191,7 +191,7 @@ Feature: define matcher
|
|
191
191
|
Then the exit status should be 0
|
192
192
|
And the stdout should contain "1 example, 0 failures"
|
193
193
|
|
194
|
-
Scenario: scoped
|
194
|
+
Scenario: scoped in a module
|
195
195
|
Given a file named "scoped_matcher_spec.rb" with:
|
196
196
|
"""
|
197
197
|
require 'rspec/expectations'
|
@@ -207,16 +207,52 @@ Feature: define matcher
|
|
207
207
|
describe "group with MyHelpers" do
|
208
208
|
include MyHelpers
|
209
209
|
it "has access to the defined matcher" do
|
210
|
-
|
210
|
+
5.should be_just_like(5)
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
214
|
describe "group without MyHelpers" do
|
215
215
|
it "does not have access to the defined matcher" do
|
216
|
-
|
216
|
+
expect do
|
217
|
+
5.should be_just_like(5)
|
218
|
+
end.to raise_exception
|
217
219
|
end
|
218
220
|
end
|
219
221
|
"""
|
220
222
|
|
221
223
|
When I run "rspec ./scoped_matcher_spec.rb"
|
222
|
-
Then the stdout should contain "
|
224
|
+
Then the stdout should contain "2 examples, 0 failures"
|
225
|
+
|
226
|
+
Scenario: scoped in an example group
|
227
|
+
Given a file named "scoped_matcher_spec.rb" with:
|
228
|
+
"""
|
229
|
+
require 'rspec/expectations'
|
230
|
+
|
231
|
+
describe "group with matcher" do
|
232
|
+
matcher :be_just_like do |expected|
|
233
|
+
match {|actual| actual == expected}
|
234
|
+
end
|
235
|
+
|
236
|
+
it "has access to the defined matcher" do
|
237
|
+
5.should be_just_like(5)
|
238
|
+
end
|
239
|
+
|
240
|
+
describe "nested group" do
|
241
|
+
it "has access to the defined matcher" do
|
242
|
+
5.should be_just_like(5)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "group without matcher" do
|
249
|
+
it "does not have access to the defined matcher" do
|
250
|
+
expect do
|
251
|
+
5.should be_just_like(5)
|
252
|
+
end.to raise_exception
|
253
|
+
end
|
254
|
+
end
|
255
|
+
"""
|
256
|
+
|
257
|
+
When I run "rspec scoped_matcher_spec.rb"
|
258
|
+
Then the output should contain "3 examples, 0 failures"
|
data/lib/rspec/matchers/dsl.rb
CHANGED
@@ -97,8 +97,8 @@ module RSpec
|
|
97
97
|
# lambda { do_something_risky }.should_not throw_symbol
|
98
98
|
# lambda { do_something_risky }.should_not throw_symbol(:that_was_risky)
|
99
99
|
# lambda { do_something_risky }.should_not throw_symbol(:that_was_risky, culprit)
|
100
|
-
def throw_symbol(
|
101
|
-
Matchers::ThrowSymbol.new(
|
100
|
+
def throw_symbol(expected_symbol = nil, expected_arg=nil)
|
101
|
+
Matchers::ThrowSymbol.new(expected_symbol, expected_arg)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
data/rspec-expectations.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-expectations}
|
8
|
-
s.version = "2.0.0.beta.
|
8
|
+
s.version = "2.0.0.beta.20"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Chelimsky", "Chad Humphries"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-08-24}
|
13
13
|
s.description = %q{rspec expectations (should[_not] and matchers)}
|
14
14
|
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
"lib/rspec/expectations/differ.rb",
|
44
44
|
"lib/rspec/expectations/errors.rb",
|
45
45
|
"lib/rspec/expectations/extensions.rb",
|
46
|
+
"lib/rspec/expectations/extensions/array.rb",
|
46
47
|
"lib/rspec/expectations/extensions/kernel.rb",
|
47
48
|
"lib/rspec/expectations/extensions/rspec/core/example_group.rb",
|
48
49
|
"lib/rspec/expectations/fail_with.rb",
|
@@ -111,17 +112,11 @@ Gem::Specification.new do |s|
|
|
111
112
|
"specs.watchr"
|
112
113
|
]
|
113
114
|
s.homepage = %q{http://github.com/rspec/expectations}
|
114
|
-
s.post_install_message = %q{**************************************************
|
115
|
-
|
116
|
-
Thank you for installing rspec-expectations-2.0.0.beta.19
|
117
|
-
|
118
|
-
**************************************************
|
119
|
-
}
|
120
115
|
s.rdoc_options = ["--charset=UTF-8"]
|
121
116
|
s.require_paths = ["lib"]
|
122
117
|
s.rubyforge_project = %q{rspec}
|
123
118
|
s.rubygems_version = %q{1.3.7}
|
124
|
-
s.summary = %q{rspec-expectations-2.0.0.beta.
|
119
|
+
s.summary = %q{rspec-expectations-2.0.0.beta.20}
|
125
120
|
s.test_files = [
|
126
121
|
"spec/rspec/expectations/differ_spec.rb",
|
127
122
|
"spec/rspec/expectations/extensions/kernel_spec.rb",
|
@@ -164,21 +159,21 @@ Gem::Specification.new do |s|
|
|
164
159
|
s.add_runtime_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
165
160
|
s.add_development_dependency(%q<cucumber>, [">= 0.6.2"])
|
166
161
|
s.add_development_dependency(%q<aruba>, [">= 0.1.1"])
|
167
|
-
s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.beta.
|
168
|
-
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
162
|
+
s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.beta.20"])
|
163
|
+
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.20"])
|
169
164
|
else
|
170
165
|
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
171
166
|
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
172
167
|
s.add_dependency(%q<aruba>, [">= 0.1.1"])
|
173
|
-
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.
|
174
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
168
|
+
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.20"])
|
169
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.20"])
|
175
170
|
end
|
176
171
|
else
|
177
172
|
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
178
173
|
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
179
174
|
s.add_dependency(%q<aruba>, [">= 0.1.1"])
|
180
|
-
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.
|
181
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
175
|
+
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.20"])
|
176
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.20"])
|
182
177
|
end
|
183
178
|
end
|
184
179
|
|
@@ -26,7 +26,7 @@ describe "Diff" do
|
|
26
26
|
@differ = RSpec::Expectations::Differ.new(@options)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "outputs unified diff of two strings" do
|
30
30
|
expected="foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n"
|
31
31
|
actual="foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n"
|
32
32
|
expected_diff= <<'EOD'
|
@@ -52,7 +52,7 @@ EOD
|
|
52
52
|
diff.should eql(expected_diff)
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "outputs unified diff message of two arrays" do
|
56
56
|
expected = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'charlie', :width, 'quite wide' ]
|
57
57
|
actual = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'tango' , :width, 'very wide' ]
|
58
58
|
|
@@ -75,7 +75,7 @@ EOD
|
|
75
75
|
diff.should == expected_diff
|
76
76
|
end
|
77
77
|
|
78
|
-
it "
|
78
|
+
it "outputs unified diff message of two objects" do
|
79
79
|
expected = RSpec::Fixtures::Animal.new "bob", "giraffe"
|
80
80
|
actual = RSpec::Fixtures::Animal.new "bob", "tortoise"
|
81
81
|
|
@@ -184,7 +184,7 @@ module RSpec
|
|
184
184
|
describe PositiveExpectationHandler do
|
185
185
|
include ExampleExpectations
|
186
186
|
|
187
|
-
it "
|
187
|
+
it "handles submitted args" do
|
188
188
|
5.should arbitrary_matcher(:expected => 5)
|
189
189
|
5.should arbitrary_matcher(:expected => "wrong").with(5)
|
190
190
|
lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5")
|
@@ -195,7 +195,7 @@ module RSpec
|
|
195
195
|
lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5")
|
196
196
|
end
|
197
197
|
|
198
|
-
it "
|
198
|
+
it "handles the submitted block" do
|
199
199
|
5.should arbitrary_matcher { 5 }
|
200
200
|
5.should arbitrary_matcher(:expected => 4) { 5 }
|
201
201
|
5.should arbitrary_matcher(:expected => 4).with(5) { 3 }
|
@@ -1,37 +1,37 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "should be_predicate" do
|
4
|
-
it "
|
4
|
+
it "passes when actual returns true for :predicate?" do
|
5
5
|
actual = stub("actual", :happy? => true)
|
6
6
|
actual.should be_happy
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "passes when actual returns true for :predicates? (present tense)" do
|
10
10
|
actual = stub("actual", :exists? => true, :exist? => true)
|
11
11
|
actual.should be_exist
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
14
|
+
it "fails when actual returns false for :predicate?" do
|
15
15
|
actual = stub("actual", :happy? => false)
|
16
16
|
lambda {
|
17
17
|
actual.should be_happy
|
18
18
|
}.should fail_with("expected happy? to return true, got false")
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "fails when actual returns false for :predicate?" do
|
22
22
|
actual = stub("actual", :happy? => nil)
|
23
23
|
lambda {
|
24
24
|
actual.should be_happy
|
25
25
|
}.should fail_with("expected happy? to return true, got nil")
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "fails when actual does not respond to :predicate?" do
|
29
29
|
lambda {
|
30
30
|
Object.new.should be_happy
|
31
31
|
}.should raise_error(NameError, /happy\?/)
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "fails on error other than NameError" do
|
35
35
|
actual = stub("actual")
|
36
36
|
actual.should_receive(:foo?).and_raise("aaaah")
|
37
37
|
lambda {
|
@@ -39,7 +39,7 @@ describe "should be_predicate" do
|
|
39
39
|
}.should raise_error(/aaaah/)
|
40
40
|
end
|
41
41
|
|
42
|
-
it "
|
42
|
+
it "fails on error other than NameError (with the present tense predicate)" do
|
43
43
|
actual = Object.new
|
44
44
|
actual.should_receive(:foos?).and_raise("aaaah")
|
45
45
|
lambda {
|
@@ -49,24 +49,24 @@ describe "should be_predicate" do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "should_not be_predicate" do
|
52
|
-
it "
|
52
|
+
it "passes when actual returns false for :sym?" do
|
53
53
|
actual = stub("actual", :happy? => false)
|
54
54
|
actual.should_not be_happy
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "passes when actual returns nil for :sym?" do
|
58
58
|
actual = stub("actual", :happy? => nil)
|
59
59
|
actual.should_not be_happy
|
60
60
|
end
|
61
61
|
|
62
|
-
it "
|
62
|
+
it "fails when actual returns true for :sym?" do
|
63
63
|
actual = stub("actual", :happy? => true)
|
64
64
|
lambda {
|
65
65
|
actual.should_not be_happy
|
66
66
|
}.should fail_with("expected happy? to return false, got true")
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
69
|
+
it "fails when actual does not respond to :sym?" do
|
70
70
|
lambda {
|
71
71
|
Object.new.should_not be_happy
|
72
72
|
}.should raise_error(NameError)
|
@@ -74,13 +74,13 @@ describe "should_not be_predicate" do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "should be_predicate(*args)" do
|
77
|
-
it "
|
77
|
+
it "passes when actual returns true for :predicate?(*args)" do
|
78
78
|
actual = mock("actual")
|
79
79
|
actual.should_receive(:older_than?).with(3).and_return(true)
|
80
80
|
actual.should be_older_than(3)
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
83
|
+
it "fails when actual returns false for :predicate?(*args)" do
|
84
84
|
actual = mock("actual")
|
85
85
|
actual.should_receive(:older_than?).with(3).and_return(false)
|
86
86
|
lambda {
|
@@ -88,7 +88,7 @@ describe "should be_predicate(*args)" do
|
|
88
88
|
}.should fail_with("expected older_than?(3) to return true, got false")
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
91
|
+
it "fails when actual does not respond to :predicate?" do
|
92
92
|
lambda {
|
93
93
|
Object.new.should be_older_than(3)
|
94
94
|
}.should raise_error(NameError)
|
@@ -96,13 +96,13 @@ describe "should be_predicate(*args)" do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
describe "should_not be_predicate(*args)" do
|
99
|
-
it "
|
99
|
+
it "passes when actual returns false for :predicate?(*args)" do
|
100
100
|
actual = mock("actual")
|
101
101
|
actual.should_receive(:older_than?).with(3).and_return(false)
|
102
102
|
actual.should_not be_older_than(3)
|
103
103
|
end
|
104
104
|
|
105
|
-
it "
|
105
|
+
it "fails when actual returns true for :predicate?(*args)" do
|
106
106
|
actual = mock("actual")
|
107
107
|
actual.should_receive(:older_than?).with(3).and_return(true)
|
108
108
|
lambda {
|
@@ -110,7 +110,7 @@ describe "should_not be_predicate(*args)" do
|
|
110
110
|
}.should fail_with("expected older_than?(3) to return false, got true")
|
111
111
|
end
|
112
112
|
|
113
|
-
it "
|
113
|
+
it "fails when actual does not respond to :predicate?" do
|
114
114
|
lambda {
|
115
115
|
Object.new.should_not be_older_than(3)
|
116
116
|
}.should raise_error(NameError)
|
@@ -118,7 +118,7 @@ describe "should_not be_predicate(*args)" do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "should be_predicate(&block)" do
|
121
|
-
it "
|
121
|
+
it "passes when actual returns true for :predicate?(&block)" do
|
122
122
|
actual = mock("actual")
|
123
123
|
delegate = mock("delegate")
|
124
124
|
actual.should_receive(:happy?).and_yield
|
@@ -126,7 +126,7 @@ describe "should be_predicate(&block)" do
|
|
126
126
|
actual.should be_happy { delegate.check_happy }
|
127
127
|
end
|
128
128
|
|
129
|
-
it "
|
129
|
+
it "fails when actual returns false for :predicate?(&block)" do
|
130
130
|
actual = mock("actual")
|
131
131
|
delegate = mock("delegate")
|
132
132
|
actual.should_receive(:happy?).and_yield
|
@@ -136,7 +136,7 @@ describe "should be_predicate(&block)" do
|
|
136
136
|
}.should fail_with("expected happy? to return true, got false")
|
137
137
|
end
|
138
138
|
|
139
|
-
it "
|
139
|
+
it "fails when actual does not respond to :predicate?" do
|
140
140
|
delegate = mock("delegate", :check_happy => true)
|
141
141
|
lambda {
|
142
142
|
Object.new.should be_happy { delegate.check_happy }
|
@@ -145,7 +145,7 @@ describe "should be_predicate(&block)" do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
describe "should_not be_predicate(&block)" do
|
148
|
-
it "
|
148
|
+
it "passes when actual returns false for :predicate?(&block)" do
|
149
149
|
actual = mock("actual")
|
150
150
|
delegate = mock("delegate")
|
151
151
|
actual.should_receive(:happy?).and_yield
|
@@ -153,7 +153,7 @@ describe "should_not be_predicate(&block)" do
|
|
153
153
|
actual.should_not be_happy { delegate.check_happy }
|
154
154
|
end
|
155
155
|
|
156
|
-
it "
|
156
|
+
it "fails when actual returns true for :predicate?(&block)" do
|
157
157
|
actual = mock("actual")
|
158
158
|
delegate = mock("delegate")
|
159
159
|
actual.should_receive(:happy?).and_yield
|
@@ -163,7 +163,7 @@ describe "should_not be_predicate(&block)" do
|
|
163
163
|
}.should fail_with("expected happy? to return false, got true")
|
164
164
|
end
|
165
165
|
|
166
|
-
it "
|
166
|
+
it "fails when actual does not respond to :predicate?" do
|
167
167
|
delegate = mock("delegate", :check_happy => true)
|
168
168
|
lambda {
|
169
169
|
Object.new.should_not be_happy { delegate.check_happy }
|
@@ -172,7 +172,7 @@ describe "should_not be_predicate(&block)" do
|
|
172
172
|
end
|
173
173
|
|
174
174
|
describe "should be_predicate(*args, &block)" do
|
175
|
-
it "
|
175
|
+
it "passes when actual returns true for :predicate?(*args, &block)" do
|
176
176
|
actual = mock("actual")
|
177
177
|
delegate = mock("delegate")
|
178
178
|
actual.should_receive(:older_than?).with(3).and_yield(3)
|
@@ -180,7 +180,7 @@ describe "should be_predicate(*args, &block)" do
|
|
180
180
|
actual.should be_older_than(3) { |age| delegate.check_older_than(age) }
|
181
181
|
end
|
182
182
|
|
183
|
-
it "
|
183
|
+
it "fails when actual returns false for :predicate?(*args, &block)" do
|
184
184
|
actual = mock("actual")
|
185
185
|
delegate = mock("delegate")
|
186
186
|
actual.should_receive(:older_than?).with(3).and_yield(3)
|
@@ -190,7 +190,7 @@ describe "should be_predicate(*args, &block)" do
|
|
190
190
|
}.should fail_with("expected older_than?(3) to return true, got false")
|
191
191
|
end
|
192
192
|
|
193
|
-
it "
|
193
|
+
it "fails when actual does not respond to :predicate?" do
|
194
194
|
delegate = mock("delegate", :check_older_than => true)
|
195
195
|
lambda {
|
196
196
|
Object.new.should be_older_than(3) { |age| delegate.check_older_than(age) }
|
@@ -199,7 +199,7 @@ describe "should be_predicate(*args, &block)" do
|
|
199
199
|
end
|
200
200
|
|
201
201
|
describe "should_not be_predicate(*args, &block)" do
|
202
|
-
it "
|
202
|
+
it "passes when actual returns false for :predicate?(*args, &block)" do
|
203
203
|
actual = mock("actual")
|
204
204
|
delegate = mock("delegate")
|
205
205
|
actual.should_receive(:older_than?).with(3).and_yield(3)
|
@@ -207,7 +207,7 @@ describe "should_not be_predicate(*args, &block)" do
|
|
207
207
|
actual.should_not be_older_than(3) { |age| delegate.check_older_than(age) }
|
208
208
|
end
|
209
209
|
|
210
|
-
it "
|
210
|
+
it "fails when actual returns true for :predicate?(*args, &block)" do
|
211
211
|
actual = mock("actual")
|
212
212
|
delegate = mock("delegate")
|
213
213
|
actual.should_receive(:older_than?).with(3).and_yield(3)
|
@@ -217,7 +217,7 @@ describe "should_not be_predicate(*args, &block)" do
|
|
217
217
|
}.should fail_with("expected older_than?(3) to return false, got true")
|
218
218
|
end
|
219
219
|
|
220
|
-
it "
|
220
|
+
it "fails when actual does not respond to :predicate?" do
|
221
221
|
delegate = mock("delegate", :check_older_than => true)
|
222
222
|
lambda {
|
223
223
|
Object.new.should_not be_older_than(3) { |age| delegate.check_older_than(age) }
|
@@ -226,15 +226,15 @@ describe "should_not be_predicate(*args, &block)" do
|
|
226
226
|
end
|
227
227
|
|
228
228
|
describe "should be_true" do
|
229
|
-
it "
|
229
|
+
it "passes when actual equal?(true)" do
|
230
230
|
true.should be_true
|
231
231
|
end
|
232
232
|
|
233
|
-
it "
|
233
|
+
it "passes when actual is 1" do
|
234
234
|
1.should be_true
|
235
235
|
end
|
236
236
|
|
237
|
-
it "
|
237
|
+
it "fails when actual equal?(false)" do
|
238
238
|
lambda {
|
239
239
|
false.should be_true
|
240
240
|
}.should fail_with("expected false to be true")
|
@@ -242,15 +242,15 @@ describe "should be_true" do
|
|
242
242
|
end
|
243
243
|
|
244
244
|
describe "should be_false" do
|
245
|
-
it "
|
245
|
+
it "passes when actual equal?(false)" do
|
246
246
|
false.should be_false
|
247
247
|
end
|
248
248
|
|
249
|
-
it "
|
249
|
+
it "passes when actual equal?(nil)" do
|
250
250
|
nil.should be_false
|
251
251
|
end
|
252
252
|
|
253
|
-
it "
|
253
|
+
it "fails when actual equal?(true)" do
|
254
254
|
lambda {
|
255
255
|
true.should be_false
|
256
256
|
}.should fail_with("expected true to be false")
|
@@ -258,11 +258,11 @@ describe "should be_false" do
|
|
258
258
|
end
|
259
259
|
|
260
260
|
describe "should be_nil" do
|
261
|
-
it "
|
261
|
+
it "passes when actual is nil" do
|
262
262
|
nil.should be_nil
|
263
263
|
end
|
264
264
|
|
265
|
-
it "
|
265
|
+
it "fails when actual is not nil" do
|
266
266
|
lambda {
|
267
267
|
:not_nil.should be_nil
|
268
268
|
}.should fail_with("expected nil, got :not_nil")
|
@@ -270,11 +270,11 @@ describe "should be_nil" do
|
|
270
270
|
end
|
271
271
|
|
272
272
|
describe "should_not be_nil" do
|
273
|
-
it "
|
273
|
+
it "passes when actual is not nil" do
|
274
274
|
:not_nil.should_not be_nil
|
275
275
|
end
|
276
276
|
|
277
|
-
it "
|
277
|
+
it "fails when actual is nil" do
|
278
278
|
lambda {
|
279
279
|
nil.should_not be_nil
|
280
280
|
}.should fail_with("expected not nil, got nil")
|
@@ -282,73 +282,73 @@ describe "should_not be_nil" do
|
|
282
282
|
end
|
283
283
|
|
284
284
|
describe "should be <" do
|
285
|
-
it "
|
285
|
+
it "passes when < operator returns true" do
|
286
286
|
3.should be < 4
|
287
287
|
end
|
288
288
|
|
289
|
-
it "
|
289
|
+
it "fails when < operator returns false" do
|
290
290
|
lambda { 3.should be < 3 }.should fail_with("expected < 3, got 3")
|
291
291
|
end
|
292
292
|
|
293
|
-
it "
|
293
|
+
it "describes itself" do
|
294
294
|
be.<(4).description.should == "be < 4"
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
298
|
describe "should be <=" do
|
299
|
-
it "
|
299
|
+
it "passes when <= operator returns true" do
|
300
300
|
3.should be <= 4
|
301
301
|
4.should be <= 4
|
302
302
|
end
|
303
303
|
|
304
|
-
it "
|
304
|
+
it "fails when <= operator returns false" do
|
305
305
|
lambda { 3.should be <= 2 }.should fail_with("expected <= 2, got 3")
|
306
306
|
end
|
307
307
|
end
|
308
308
|
|
309
309
|
describe "should be >=" do
|
310
|
-
it "
|
310
|
+
it "passes when >= operator returns true" do
|
311
311
|
4.should be >= 4
|
312
312
|
5.should be >= 4
|
313
313
|
end
|
314
314
|
|
315
|
-
it "
|
315
|
+
it "fails when >= operator returns false" do
|
316
316
|
lambda { 3.should be >= 4 }.should fail_with("expected >= 4, got 3")
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
320
320
|
describe "should be >" do
|
321
|
-
it "
|
321
|
+
it "passes when > operator returns true" do
|
322
322
|
5.should be > 4
|
323
323
|
end
|
324
324
|
|
325
|
-
it "
|
325
|
+
it "fails when > operator returns false" do
|
326
326
|
lambda { 3.should be > 4 }.should fail_with("expected > 4, got 3")
|
327
327
|
end
|
328
328
|
end
|
329
329
|
|
330
330
|
describe "should be ==" do
|
331
|
-
it "
|
331
|
+
it "passes when == operator returns true" do
|
332
332
|
5.should be == 5
|
333
333
|
end
|
334
334
|
|
335
|
-
it "
|
335
|
+
it "fails when == operator returns false" do
|
336
336
|
lambda { 3.should be == 4 }.should fail_with("expected == 4, got 3")
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
340
340
|
describe "should be ===" do
|
341
|
-
it "
|
341
|
+
it "passes when === operator returns true" do
|
342
342
|
Hash.should be === Hash.new
|
343
343
|
end
|
344
344
|
|
345
|
-
it "
|
345
|
+
it "fails when === operator returns false" do
|
346
346
|
lambda { Hash.should be === "not a hash" }.should fail_with(%[expected === not a hash, got Hash])
|
347
347
|
end
|
348
348
|
end
|
349
349
|
|
350
350
|
describe "should_not with operators" do
|
351
|
-
it "
|
351
|
+
it "coaches user to stop using operators with should_not" do
|
352
352
|
lambda {
|
353
353
|
5.should_not be < 6
|
354
354
|
}.should raise_error(/not only FAILED,\nit is a bit confusing./m)
|
@@ -356,60 +356,60 @@ describe "should_not with operators" do
|
|
356
356
|
end
|
357
357
|
|
358
358
|
describe "should be" do
|
359
|
-
it "
|
359
|
+
it "passes if actual is truthy" do
|
360
360
|
true.should be
|
361
361
|
1.should be
|
362
362
|
end
|
363
363
|
|
364
|
-
it "
|
364
|
+
it "fails if actual is false" do
|
365
365
|
lambda {false.should be}.should fail_with("expected false to evaluate to true")
|
366
366
|
end
|
367
367
|
|
368
|
-
it "
|
368
|
+
it "fails if actual is nil" do
|
369
369
|
lambda {nil.should be}.should fail_with("expected nil to evaluate to true")
|
370
370
|
end
|
371
371
|
|
372
|
-
it "
|
372
|
+
it "describes itself" do
|
373
373
|
be.description.should == "be"
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
377
377
|
describe "should_not be" do
|
378
|
-
it "
|
378
|
+
it "passes if actual is falsy" do
|
379
379
|
false.should_not be
|
380
380
|
nil.should_not be
|
381
381
|
end
|
382
382
|
|
383
|
-
it "
|
383
|
+
it "fails on true" do
|
384
384
|
lambda {true.should_not be}.should fail_with("expected true to evaluate to false")
|
385
385
|
end
|
386
386
|
end
|
387
387
|
|
388
388
|
describe "should be(value)" do
|
389
|
-
it "
|
389
|
+
it "passes if actual.equal?(value)" do
|
390
390
|
5.should be(5)
|
391
391
|
end
|
392
392
|
|
393
|
-
it "
|
393
|
+
it "fails if !actual.equal?(value)" do
|
394
394
|
lambda { 5.should be(6) }.should fail_with("expected 6, got 5")
|
395
395
|
end
|
396
396
|
|
397
|
-
it "
|
397
|
+
it "describes itself" do
|
398
398
|
be(5).description.should == "be 5"
|
399
399
|
end
|
400
400
|
end
|
401
401
|
|
402
402
|
describe "should_not be(value)" do
|
403
|
-
it "
|
403
|
+
it "passes if !actual.equal?(value)" do
|
404
404
|
5.should_not be(6)
|
405
405
|
end
|
406
|
-
it "
|
406
|
+
it "fails if !actual.equal?(value)" do
|
407
407
|
lambda { 5.should_not be(5) }.should fail_with("expected not 5, got 5")
|
408
408
|
end
|
409
409
|
end
|
410
410
|
|
411
411
|
describe "'should be' with operator" do
|
412
|
-
it "
|
412
|
+
it "includes 'be' in the description" do
|
413
413
|
(be > 6).description.should =~ /be > 6/
|
414
414
|
(be >= 6).description.should =~ /be >= 6/
|
415
415
|
(be <= 6).description.should =~ /be <= 6/
|
@@ -419,7 +419,7 @@ end
|
|
419
419
|
|
420
420
|
|
421
421
|
describe "arbitrary predicate with DelegateClass" do
|
422
|
-
it "
|
422
|
+
it "accesses methods defined in the delegating class (LH[#48])" do
|
423
423
|
pending("this fails in 1.9.2-preview3") unless RUBY_VERSION.to_s =~ /^1.8/
|
424
424
|
require 'delegate'
|
425
425
|
class ArrayDelegate < DelegateClass(Array)
|
@@ -439,12 +439,12 @@ describe "arbitrary predicate with DelegateClass" do
|
|
439
439
|
end
|
440
440
|
|
441
441
|
describe "be_a, be_an" do
|
442
|
-
it "
|
442
|
+
it "passes when class matches" do
|
443
443
|
"foobar".should be_a(String)
|
444
444
|
[1,2,3].should be_an(Array)
|
445
445
|
end
|
446
446
|
|
447
|
-
it "
|
447
|
+
it "fails when class does not match" do
|
448
448
|
"foobar".should_not be_a(Hash)
|
449
449
|
[1,2,3].should_not be_an(Integer)
|
450
450
|
end
|