rr 0.4.2 → 0.4.3
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/CHANGES +5 -0
- data/README +13 -0
- data/Rakefile +1 -1
- data/lib/rr.rb +3 -3
- data/lib/rr/adapters/rr_methods.rb +5 -5
- data/lib/rr/double.rb +5 -5
- data/lib/rr/double_creator.rb +13 -13
- data/lib/rr/double_definition.rb +3 -3
- data/lib/rr/double_injection.rb +24 -24
- data/lib/rr/double_matches.rb +29 -29
- data/lib/rr/errors/{scenario_definition_error.rb → double_definition_error.rb} +0 -0
- data/lib/rr/errors/{scenario_not_found_error.rb → double_not_found_error.rb} +0 -0
- data/lib/rr/errors/{scenario_order_error.rb → double_order_error.rb} +0 -0
- data/lib/rr/expectations/times_called_expectation.rb +4 -4
- data/lib/rr/space.rb +22 -22
- data/spec/rr/adapters/rr_methods_creator_spec.rb +69 -69
- data/spec/rr/adapters/rr_methods_space_spec.rb +11 -11
- data/spec/rr/double/double_injection_dispatching_spec.rb +66 -66
- data/spec/rr/double/double_injection_register_scenario_spec.rb +8 -8
- data/spec/rr/double/double_injection_verify_spec.rb +4 -4
- data/spec/rr/double_creator_spec.rb +65 -65
- data/spec/rr/double_definition_spec.rb +9 -9
- data/spec/rr/double_method_proxy_spec.rb +7 -7
- data/spec/rr/double_spec.rb +199 -199
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +3 -3
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +1 -1
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb +4 -4
- data/spec/rr/rspec/rspec_adapter_spec.rb +2 -2
- data/spec/rr/space/space_create_spec.rb +37 -37
- data/spec/rr/space/space_register_spec.rb +9 -9
- data/spec/rr/space/space_reset_spec.rb +7 -7
- data/spec/rr/space/space_verify_spec.rb +31 -31
- metadata +5 -5
@@ -28,11 +28,11 @@ module RR
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "creates a mock Double for method when passed a second argument" do
|
31
|
-
|
31
|
+
creates_double_with_method_name(mock(@subject, :foobar))
|
32
32
|
end
|
33
33
|
|
34
34
|
it "creates a mock Double for method when passed a second argument with rr_mock" do
|
35
|
-
|
35
|
+
creates_double_with_method_name(rr_mock(@subject, :foobar))
|
36
36
|
end
|
37
37
|
|
38
38
|
it "raises error if passed a method name and a block" do
|
@@ -41,20 +41,20 @@ module RR
|
|
41
41
|
end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
def creates_double_with_method_name(double)
|
45
|
+
double.with(1, 2) {:baz}
|
46
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
47
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
48
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
49
49
|
|
50
50
|
@subject.foobar(1, 2).should == :baz
|
51
51
|
end
|
52
52
|
|
53
53
|
def creates_mock_call_chain(creator)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
double = creator.foobar(1, 2) {:baz}
|
55
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
56
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
57
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
58
58
|
|
59
59
|
@subject.foobar(1, 2).should == :baz
|
60
60
|
end
|
@@ -85,11 +85,11 @@ module RR
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it "creates a stub Double for method when passed a second argument" do
|
88
|
-
|
88
|
+
creates_double_with_method_name(stub(@subject, :foobar))
|
89
89
|
end
|
90
90
|
|
91
91
|
it "#rr_stub creates a stub Double for method when passed a second argument" do
|
92
|
-
|
92
|
+
creates_double_with_method_name(rr_stub(@subject, :foobar))
|
93
93
|
end
|
94
94
|
|
95
95
|
it "raises error if passed a method name and a block" do
|
@@ -98,17 +98,17 @@ module RR
|
|
98
98
|
end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
def creates_double_with_method_name(double)
|
102
|
+
double.with(1, 2) {:baz}
|
103
|
+
double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
104
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
105
105
|
@subject.foobar(1, 2).should == :baz
|
106
106
|
end
|
107
107
|
|
108
108
|
def creates_stub_call_chain(creator)
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
double = creator.foobar(1, 2) {:baz}
|
110
|
+
double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
111
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
112
112
|
@subject.foobar(1, 2).should == :baz
|
113
113
|
end
|
114
114
|
end
|
@@ -146,19 +146,19 @@ module RR
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it "#proxy creates a mock Double for method when passed a second argument" do
|
149
|
-
|
149
|
+
creates_double_with_method_name(mock.proxy(@subject, :foobar))
|
150
150
|
end
|
151
151
|
|
152
152
|
it "#rr_proxy creates a mock Double for method when passed a second argument with rr_mock" do
|
153
|
-
|
153
|
+
creates_double_with_method_name(rr_proxy.mock(@subject, :foobar))
|
154
154
|
end
|
155
155
|
|
156
156
|
it "#mock_proxy creates a mock Double for method when passed a second argument" do
|
157
|
-
|
157
|
+
creates_double_with_method_name(mock.proxy(@subject, :foobar))
|
158
158
|
end
|
159
159
|
|
160
160
|
it "#rr_mock_proxy creates a mock Double for method when passed a second argument with rr_mock" do
|
161
|
-
|
161
|
+
creates_double_with_method_name(rr_mock.proxy(@subject, :foobar))
|
162
162
|
end
|
163
163
|
|
164
164
|
it "raises error if passed a method name and a block" do
|
@@ -167,20 +167,20 @@ module RR
|
|
167
167
|
end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
|
168
168
|
end
|
169
169
|
|
170
|
-
def
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
170
|
+
def creates_double_with_method_name(double)
|
171
|
+
double.with(1, 2)
|
172
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
173
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
174
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
175
175
|
|
176
176
|
@subject.foobar(1, 2).should == :original_value
|
177
177
|
end
|
178
178
|
|
179
179
|
def creates_mock_proxy_call_chain(creator)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
180
|
+
double = creator.foobar(1, 2)
|
181
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
182
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
183
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
184
184
|
|
185
185
|
@subject.foobar(1, 2).should == :original_value
|
186
186
|
end
|
@@ -211,11 +211,11 @@ module RR
|
|
211
211
|
end
|
212
212
|
|
213
213
|
it "#stub.proxy creates a stub Double for method when passed a second argument" do
|
214
|
-
|
214
|
+
creates_double_with_method_name(stub.proxy(@subject, :foobar))
|
215
215
|
end
|
216
216
|
|
217
217
|
it "#rr_stub.proxy creates a stub Double for method when passed a second argument with rr_stub" do
|
218
|
-
|
218
|
+
creates_double_with_method_name(rr_stub.proxy(@subject, :foobar))
|
219
219
|
end
|
220
220
|
|
221
221
|
it "raises error if passed a method name and a block" do
|
@@ -224,17 +224,17 @@ module RR
|
|
224
224
|
end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
|
225
225
|
end
|
226
226
|
|
227
|
-
def
|
228
|
-
|
229
|
-
|
227
|
+
def creates_double_with_method_name(double)
|
228
|
+
double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
229
|
+
double.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
230
230
|
|
231
231
|
@subject.foobar(:something).should == :original_value
|
232
232
|
end
|
233
233
|
|
234
234
|
def creates_stub_proxy_call_chain(creator)
|
235
|
-
|
236
|
-
|
237
|
-
|
235
|
+
double = creator.foobar
|
236
|
+
double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
|
237
|
+
double.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
238
238
|
|
239
239
|
@subject.foobar(1, 2).should == :original_value
|
240
240
|
end
|
@@ -268,14 +268,14 @@ module RR
|
|
268
268
|
end
|
269
269
|
|
270
270
|
it "creates a mock Double for method when passed a second argument" do
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
271
|
+
creates_double_with_method_name(dont_allow(@subject, :foobar))
|
272
|
+
creates_double_with_method_name(rr_dont_allow(@subject, :foobar))
|
273
|
+
creates_double_with_method_name(dont_call(@subject, :foobar))
|
274
|
+
creates_double_with_method_name(rr_dont_call(@subject, :foobar))
|
275
|
+
creates_double_with_method_name(do_not_allow(@subject, :foobar))
|
276
|
+
creates_double_with_method_name(rr_do_not_allow(@subject, :foobar))
|
277
|
+
creates_double_with_method_name(dont_allow(@subject, :foobar))
|
278
|
+
creates_double_with_method_name(rr_dont_allow(@subject, :foobar))
|
279
279
|
end
|
280
280
|
|
281
281
|
it "raises error if passed a method name and a block" do
|
@@ -284,11 +284,11 @@ module RR
|
|
284
284
|
end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
|
285
285
|
end
|
286
286
|
|
287
|
-
def
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
287
|
+
def creates_double_with_method_name(double)
|
288
|
+
double.with(1, 2)
|
289
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
|
290
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
291
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
292
292
|
|
293
293
|
proc do
|
294
294
|
@subject.foobar(1, 2)
|
@@ -298,10 +298,10 @@ module RR
|
|
298
298
|
end
|
299
299
|
|
300
300
|
def creates_do_not_allow_call_chain(creator)
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
301
|
+
double = creator.foobar(1, 2)
|
302
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
|
303
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
304
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
305
305
|
|
306
306
|
proc do
|
307
307
|
@subject.foobar(1, 2)
|
@@ -329,11 +329,11 @@ module RR
|
|
329
329
|
end
|
330
330
|
|
331
331
|
it "creates a instance_of Double for method when passed a second argument" do
|
332
|
-
|
332
|
+
creates_double_with_method_name(instance_of.mock(@klass, :foobar))
|
333
333
|
end
|
334
334
|
|
335
335
|
it "creates a instance_of Double for method when passed a second argument with rr_instance_of" do
|
336
|
-
|
336
|
+
creates_double_with_method_name(rr_instance_of.mock(@klass, :foobar))
|
337
337
|
end
|
338
338
|
|
339
339
|
it "raises error if passed a method name and a block" do
|
@@ -342,20 +342,20 @@ module RR
|
|
342
342
|
end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
|
343
343
|
end
|
344
344
|
|
345
|
-
def
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
345
|
+
def creates_double_with_method_name(double)
|
346
|
+
double.with(1, 2) {:baz}
|
347
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
348
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
349
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
350
350
|
|
351
351
|
@klass.new.foobar(1, 2).should == :baz
|
352
352
|
end
|
353
353
|
|
354
354
|
def creates_instance_of_call_chain(creator)
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
355
|
+
double = creator.foobar(1, 2) {:baz}
|
356
|
+
double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
|
357
|
+
double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
358
|
+
double.argument_expectation.expected_arguments.should == [1, 2]
|
359
359
|
|
360
360
|
@klass.new.foobar(1, 2).should == :baz
|
361
361
|
end
|
@@ -67,12 +67,12 @@ module RR
|
|
67
67
|
end
|
68
68
|
|
69
69
|
describe RRMethods, "#reset" do
|
70
|
-
it "#reset removes the ordered
|
71
|
-
|
70
|
+
it "#reset removes the ordered doubles" do
|
71
|
+
removes_ordered_doubles {reset}
|
72
72
|
end
|
73
73
|
|
74
|
-
it "#rr_reset removes the ordered
|
75
|
-
|
74
|
+
it "#rr_reset removes the ordered doubles" do
|
75
|
+
removes_ordered_doubles {rr_reset}
|
76
76
|
end
|
77
77
|
|
78
78
|
it "#reset resets all double_insertions" do
|
@@ -83,20 +83,20 @@ module RR
|
|
83
83
|
resets_all_double_insertions {rr_reset}
|
84
84
|
end
|
85
85
|
|
86
|
-
def
|
86
|
+
def removes_ordered_doubles
|
87
87
|
double1 = @space.double_insertion(@object1, :foobar1)
|
88
88
|
double2 = @space.double_insertion(@object1, :foobar2)
|
89
89
|
|
90
|
-
|
91
|
-
|
90
|
+
double1 = @space.double(double1)
|
91
|
+
double2 = @space.double(double2)
|
92
92
|
|
93
|
-
|
94
|
-
|
93
|
+
double1.ordered
|
94
|
+
double2.ordered
|
95
95
|
|
96
|
-
@space.
|
96
|
+
@space.ordered_doubles.should_not be_empty
|
97
97
|
|
98
98
|
yield
|
99
|
-
@space.
|
99
|
+
@space.ordered_doubles.should be_empty
|
100
100
|
end
|
101
101
|
|
102
102
|
def resets_all_double_insertions
|
@@ -14,7 +14,7 @@ module RR
|
|
14
14
|
:foobar
|
15
15
|
end
|
16
16
|
|
17
|
-
describe "where the
|
17
|
+
describe "where the double takes a block" do
|
18
18
|
it "executes the block" do
|
19
19
|
method_fixture = Object.new
|
20
20
|
class << method_fixture
|
@@ -22,43 +22,43 @@ module RR
|
|
22
22
|
yield(a, b)
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
|
25
|
+
double = @space.double(@double_insertion)
|
26
|
+
double.with(1, 2).implemented_by(method_fixture.method(:method_with_block))
|
27
27
|
@object.foobar(1, 2) {|a, b| [b, a]}.should == [2, 1]
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe "where there are no
|
31
|
+
describe "where there are no doubles with duplicate ArgumentExpectations" do
|
32
32
|
it "dispatches to Double that have an exact match" do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
double1_with_exact_match = @space.double(@double_insertion)
|
34
|
+
double1_with_exact_match.with(:exact_match_1).returns {:return_1}
|
35
|
+
double_with_no_match = @space.double(@double_insertion)
|
36
|
+
double_with_no_match.with("nothing that matches").returns {:no_match}
|
37
|
+
double2_with_exact_match = @space.double(@double_insertion)
|
38
|
+
double2_with_exact_match.with(:exact_match_2).returns {:return_2}
|
39
39
|
|
40
40
|
@object.foobar(:exact_match_1).should == :return_1
|
41
41
|
@object.foobar(:exact_match_2).should == :return_2
|
42
42
|
end
|
43
43
|
|
44
44
|
it "dispatches to Double that have a wildcard match" do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
double_with_wildcard_match = @space.double(@double_insertion)
|
46
|
+
double_with_wildcard_match.with_any_args.returns {:wild_card_value}
|
47
|
+
double_with_no_match = @space.double(@double_insertion)
|
48
|
+
double_with_no_match.with("nothing that matches").returns {:no_match}
|
49
49
|
|
50
50
|
@object.foobar(:wildcard_match_1).should == :wild_card_value
|
51
51
|
@object.foobar(:wildcard_match_2, 3).should == :wild_card_value
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe "where there are
|
56
|
-
it "raises DoubleNotFoundError error when arguments do not match a
|
57
|
-
|
58
|
-
|
55
|
+
describe "where there are doubles" do
|
56
|
+
it "raises DoubleNotFoundError error when arguments do not match a double" do
|
57
|
+
double_1 = @space.double(@double_insertion)
|
58
|
+
double_1.with(1, 2)
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
double_2 = @space.double(@double_insertion)
|
61
|
+
double_2.with(3)
|
62
62
|
|
63
63
|
proc {@object.foobar(:arg1, :arg2)}.should raise_error(
|
64
64
|
Errors::DoubleNotFoundError,
|
@@ -71,70 +71,70 @@ module RR
|
|
71
71
|
|
72
72
|
describe "where there are Doubles with NonTerminal TimesCalledMatchers" do
|
73
73
|
it "dispatches to Double with exact match" do
|
74
|
-
|
74
|
+
double = double(1, 2) {:return_value}
|
75
75
|
@object.foobar(1, 2).should == :return_value
|
76
76
|
end
|
77
77
|
|
78
78
|
it "matches to the last Double that was registered with an exact match" do
|
79
|
-
|
80
|
-
|
79
|
+
double_1 = double(1, 2) {:value_1}
|
80
|
+
double_2 = double(1, 2) {:value_2}
|
81
81
|
|
82
82
|
@object.foobar(1, 2).should == :value_2
|
83
83
|
end
|
84
84
|
|
85
85
|
it "dispatches to Double with wildcard match" do
|
86
|
-
|
86
|
+
double = double(anything) {:return_value}
|
87
87
|
@object.foobar(:dont_care).should == :return_value
|
88
88
|
end
|
89
89
|
|
90
90
|
it "matches to the last Double that was registered with a wildcard match" do
|
91
|
-
|
92
|
-
|
91
|
+
double_1 = double(anything) {:value_1}
|
92
|
+
double_2 = double(anything) {:value_2}
|
93
93
|
|
94
94
|
@object.foobar(:dont_care).should == :value_2
|
95
95
|
end
|
96
96
|
|
97
97
|
it "matches to Double with exact match Double even when a Double with wildcard match was registered later" do
|
98
|
-
|
99
|
-
|
98
|
+
exact_double_registered_first = double(1, 2) {:exact_first}
|
99
|
+
wildcard_double_registered_last = double(anything, anything) {:wildcard_last}
|
100
100
|
|
101
101
|
@object.foobar(1, 2).should == :exact_first
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
def double(*arguments, &return_value)
|
105
|
+
double = @space.double(@double_insertion)
|
106
|
+
double.with(*arguments).any_number_of_times.returns(&return_value)
|
107
|
+
double.should_not be_terminal
|
108
|
+
double
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
describe "where there are Terminal Doubles with duplicate Exact Match ArgumentExpectations" do
|
113
113
|
it "dispatches to Double that have an exact match" do
|
114
|
-
|
114
|
+
double1_with_exact_match = double(:exact_match) {:return_1}
|
115
115
|
|
116
116
|
@object.foobar(:exact_match).should == :return_1
|
117
117
|
end
|
118
118
|
|
119
119
|
it "dispatches to the first Double that have an exact match" do
|
120
|
-
|
121
|
-
|
120
|
+
double1_with_exact_match = double(:exact_match) {:return_1}
|
121
|
+
double2_with_exact_match = double(:exact_match) {:return_2}
|
122
122
|
|
123
123
|
@object.foobar(:exact_match).should == :return_1
|
124
124
|
end
|
125
125
|
|
126
126
|
it "dispatches the second Double with an exact match
|
127
|
-
when the first
|
128
|
-
|
129
|
-
|
127
|
+
when the first double's Times Called expectation is satisfied" do
|
128
|
+
double1_with_exact_match = double(:exact_match) {:return_1}
|
129
|
+
double2_with_exact_match = double(:exact_match) {:return_2}
|
130
130
|
|
131
131
|
@object.foobar(:exact_match)
|
132
132
|
@object.foobar(:exact_match).should == :return_2
|
133
133
|
end
|
134
134
|
|
135
|
-
it "raises TimesCalledError when all of the
|
136
|
-
|
137
|
-
|
135
|
+
it "raises TimesCalledError when all of the doubles Times Called expectation is satisfied" do
|
136
|
+
double1_with_exact_match = double(:exact_match) {:return_1}
|
137
|
+
double2_with_exact_match = double(:exact_match) {:return_2}
|
138
138
|
|
139
139
|
@object.foobar(:exact_match)
|
140
140
|
@object.foobar(:exact_match)
|
@@ -143,40 +143,40 @@ module RR
|
|
143
143
|
end.should raise_error(Errors::TimesCalledError)
|
144
144
|
end
|
145
145
|
|
146
|
-
def
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
146
|
+
def double(*arguments, &return_value)
|
147
|
+
double = @space.double(@double_insertion)
|
148
|
+
double.with(*arguments).once.returns(&return_value)
|
149
|
+
double.should be_terminal
|
150
|
+
double
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
describe "where there are
|
154
|
+
describe "where there are doubles with duplicate Wildcard Match ArgumentExpectations" do
|
155
155
|
it "dispatches to Double that have a wildcard match" do
|
156
|
-
|
156
|
+
double_1 = double {:return_1}
|
157
157
|
|
158
158
|
@object.foobar(:anything).should == :return_1
|
159
159
|
end
|
160
160
|
|
161
161
|
it "dispatches to the first Double that has a wildcard match" do
|
162
|
-
|
163
|
-
|
162
|
+
double_1 = double {:return_1}
|
163
|
+
double_2 = double {:return_2}
|
164
164
|
|
165
165
|
@object.foobar(:anything).should == :return_1
|
166
166
|
end
|
167
167
|
|
168
168
|
it "dispatches the second Double with a wildcard match
|
169
|
-
when the first
|
170
|
-
|
171
|
-
|
169
|
+
when the first double's Times Called expectation is satisfied" do
|
170
|
+
double_1 = double {:return_1}
|
171
|
+
double_2 = double {:return_2}
|
172
172
|
|
173
173
|
@object.foobar(:anything)
|
174
174
|
@object.foobar(:anything).should == :return_2
|
175
175
|
end
|
176
176
|
|
177
|
-
it "raises TimesCalledError when all of the
|
178
|
-
|
179
|
-
|
177
|
+
it "raises TimesCalledError when all of the doubles Times Called expectation is satisfied" do
|
178
|
+
double_1 = double {:return_1}
|
179
|
+
double_2 = double {:return_2}
|
180
180
|
|
181
181
|
@object.foobar(:anything)
|
182
182
|
@object.foobar(:anything)
|
@@ -185,11 +185,11 @@ module RR
|
|
185
185
|
end.should raise_error(Errors::TimesCalledError)
|
186
186
|
end
|
187
187
|
|
188
|
-
def
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
188
|
+
def double(&return_value)
|
189
|
+
double = @space.double(@double_insertion)
|
190
|
+
double.with_any_args.once.returns(&return_value)
|
191
|
+
double.should be_terminal
|
192
|
+
double
|
193
193
|
end
|
194
194
|
end
|
195
195
|
end
|
@@ -200,8 +200,8 @@ module RR
|
|
200
200
|
end
|
201
201
|
|
202
202
|
it "executes the block" do
|
203
|
-
|
204
|
-
|
203
|
+
double = @space.double(@double_insertion)
|
204
|
+
double.with(1, 2) {:return_value}
|
205
205
|
@object.foobar!(1, 2).should == :return_value
|
206
206
|
end
|
207
207
|
end
|
@@ -212,8 +212,8 @@ module RR
|
|
212
212
|
end
|
213
213
|
|
214
214
|
it "executes the block" do
|
215
|
-
|
216
|
-
|
215
|
+
double = @space.double(@double_insertion)
|
216
|
+
double.with(1, 2) {:return_value}
|
217
217
|
@object.foobar?(1, 2).should == :return_value
|
218
218
|
end
|
219
219
|
end
|