rr 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGES +5 -0
  2. data/README +13 -0
  3. data/Rakefile +1 -1
  4. data/lib/rr.rb +3 -3
  5. data/lib/rr/adapters/rr_methods.rb +5 -5
  6. data/lib/rr/double.rb +5 -5
  7. data/lib/rr/double_creator.rb +13 -13
  8. data/lib/rr/double_definition.rb +3 -3
  9. data/lib/rr/double_injection.rb +24 -24
  10. data/lib/rr/double_matches.rb +29 -29
  11. data/lib/rr/errors/{scenario_definition_error.rb → double_definition_error.rb} +0 -0
  12. data/lib/rr/errors/{scenario_not_found_error.rb → double_not_found_error.rb} +0 -0
  13. data/lib/rr/errors/{scenario_order_error.rb → double_order_error.rb} +0 -0
  14. data/lib/rr/expectations/times_called_expectation.rb +4 -4
  15. data/lib/rr/space.rb +22 -22
  16. data/spec/rr/adapters/rr_methods_creator_spec.rb +69 -69
  17. data/spec/rr/adapters/rr_methods_space_spec.rb +11 -11
  18. data/spec/rr/double/double_injection_dispatching_spec.rb +66 -66
  19. data/spec/rr/double/double_injection_register_scenario_spec.rb +8 -8
  20. data/spec/rr/double/double_injection_verify_spec.rb +4 -4
  21. data/spec/rr/double_creator_spec.rb +65 -65
  22. data/spec/rr/double_definition_spec.rb +9 -9
  23. data/spec/rr/double_method_proxy_spec.rb +7 -7
  24. data/spec/rr/double_spec.rb +199 -199
  25. data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +1 -1
  26. data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +1 -1
  27. data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +1 -1
  28. data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +3 -3
  29. data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +1 -1
  30. data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +1 -1
  31. data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +1 -1
  32. data/spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb +4 -4
  33. data/spec/rr/rspec/rspec_adapter_spec.rb +2 -2
  34. data/spec/rr/space/space_create_spec.rb +37 -37
  35. data/spec/rr/space/space_register_spec.rb +9 -9
  36. data/spec/rr/space/space_reset_spec.rb +7 -7
  37. data/spec/rr/space/space_verify_spec.rb +31 -31
  38. 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
- creates_scenario_with_method_name(mock(@subject, :foobar))
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
- creates_scenario_with_method_name(rr_mock(@subject, :foobar))
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 creates_scenario_with_method_name(scenario)
45
- scenario.with(1, 2) {:baz}
46
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
47
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
48
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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
- scenario = creator.foobar(1, 2) {:baz}
55
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
56
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
57
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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
- creates_scenario_with_method_name(stub(@subject, :foobar))
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
- creates_scenario_with_method_name(rr_stub(@subject, :foobar))
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 creates_scenario_with_method_name(scenario)
102
- scenario.with(1, 2) {:baz}
103
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
104
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
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
- scenario = creator.foobar(1, 2) {:baz}
110
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
111
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
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
- creates_scenario_with_method_name(mock.proxy(@subject, :foobar))
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
- creates_scenario_with_method_name(rr_proxy.mock(@subject, :foobar))
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
- creates_scenario_with_method_name(mock.proxy(@subject, :foobar))
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
- creates_scenario_with_method_name(rr_mock.proxy(@subject, :foobar))
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 creates_scenario_with_method_name(scenario)
171
- scenario.with(1, 2)
172
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
173
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
174
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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
- scenario = creator.foobar(1, 2)
181
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
182
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
183
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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
- creates_scenario_with_method_name(stub.proxy(@subject, :foobar))
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
- creates_scenario_with_method_name(rr_stub.proxy(@subject, :foobar))
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 creates_scenario_with_method_name(scenario)
228
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
229
- scenario.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
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
- scenario = creator.foobar
236
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
237
- scenario.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
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
- creates_scenario_with_method_name(dont_allow(@subject, :foobar))
272
- creates_scenario_with_method_name(rr_dont_allow(@subject, :foobar))
273
- creates_scenario_with_method_name(dont_call(@subject, :foobar))
274
- creates_scenario_with_method_name(rr_dont_call(@subject, :foobar))
275
- creates_scenario_with_method_name(do_not_allow(@subject, :foobar))
276
- creates_scenario_with_method_name(rr_do_not_allow(@subject, :foobar))
277
- creates_scenario_with_method_name(dont_allow(@subject, :foobar))
278
- creates_scenario_with_method_name(rr_dont_allow(@subject, :foobar))
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 creates_scenario_with_method_name(scenario)
288
- scenario.with(1, 2)
289
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
290
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
291
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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
- scenario = creator.foobar(1, 2)
302
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
303
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
304
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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
- creates_scenario_with_method_name(instance_of.mock(@klass, :foobar))
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
- creates_scenario_with_method_name(rr_instance_of.mock(@klass, :foobar))
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 creates_scenario_with_method_name(scenario)
346
- scenario.with(1, 2) {:baz}
347
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
348
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
349
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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
- scenario = creator.foobar(1, 2) {:baz}
356
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
357
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
358
- scenario.argument_expectation.expected_arguments.should == [1, 2]
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 scenarios" do
71
- removes_ordered_scenarios {reset}
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 scenarios" do
75
- removes_ordered_scenarios {rr_reset}
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 removes_ordered_scenarios
86
+ def removes_ordered_doubles
87
87
  double1 = @space.double_insertion(@object1, :foobar1)
88
88
  double2 = @space.double_insertion(@object1, :foobar2)
89
89
 
90
- scenario1 = @space.scenario(double1)
91
- scenario2 = @space.scenario(double2)
90
+ double1 = @space.double(double1)
91
+ double2 = @space.double(double2)
92
92
 
93
- scenario1.ordered
94
- scenario2.ordered
93
+ double1.ordered
94
+ double2.ordered
95
95
 
96
- @space.ordered_scenarios.should_not be_empty
96
+ @space.ordered_doubles.should_not be_empty
97
97
 
98
98
  yield
99
- @space.ordered_scenarios.should be_empty
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 scenario takes a block" do
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
- scenario = @space.scenario(@double_insertion)
26
- scenario.with(1, 2).implemented_by(method_fixture.method(:method_with_block))
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 scenarios with duplicate ArgumentExpectations" do
31
+ describe "where there are no doubles with duplicate ArgumentExpectations" do
32
32
  it "dispatches to Double that have an exact match" do
33
- scenario1_with_exact_match = @space.scenario(@double_insertion)
34
- scenario1_with_exact_match.with(:exact_match_1).returns {:return_1}
35
- scenario_with_no_match = @space.scenario(@double_insertion)
36
- scenario_with_no_match.with("nothing that matches").returns {:no_match}
37
- scenario2_with_exact_match = @space.scenario(@double_insertion)
38
- scenario2_with_exact_match.with(:exact_match_2).returns {:return_2}
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
- scenario_with_wildcard_match = @space.scenario(@double_insertion)
46
- scenario_with_wildcard_match.with_any_args.returns {:wild_card_value}
47
- scenario_with_no_match = @space.scenario(@double_insertion)
48
- scenario_with_no_match.with("nothing that matches").returns {:no_match}
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 scenarios" do
56
- it "raises DoubleNotFoundError error when arguments do not match a scenario" do
57
- scenario_1 = @space.scenario(@double_insertion)
58
- scenario_1.with(1, 2)
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
- scenario_2 = @space.scenario(@double_insertion)
61
- scenario_2.with(3)
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
- scenario = scenario(1, 2) {:return_value}
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
- scenario_1 = scenario(1, 2) {:value_1}
80
- scenario_2 = scenario(1, 2) {:value_2}
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
- scenario = scenario(anything) {:return_value}
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
- scenario_1 = scenario(anything) {:value_1}
92
- scenario_2 = scenario(anything) {:value_2}
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
- exact_scenario_registered_first = scenario(1, 2) {:exact_first}
99
- wildcard_scenario_registered_last = scenario(anything, anything) {:wildcard_last}
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 scenario(*arguments, &return_value)
105
- scenario = @space.scenario(@double_insertion)
106
- scenario.with(*arguments).any_number_of_times.returns(&return_value)
107
- scenario.should_not be_terminal
108
- scenario
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
- scenario1_with_exact_match = scenario(:exact_match) {:return_1}
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
- scenario1_with_exact_match = scenario(:exact_match) {:return_1}
121
- scenario2_with_exact_match = scenario(:exact_match) {:return_2}
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 scenario's Times Called expectation is satisfied" do
128
- scenario1_with_exact_match = scenario(:exact_match) {:return_1}
129
- scenario2_with_exact_match = scenario(:exact_match) {:return_2}
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 scenarios Times Called expectation is satisfied" do
136
- scenario1_with_exact_match = scenario(:exact_match) {:return_1}
137
- scenario2_with_exact_match = scenario(:exact_match) {:return_2}
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 scenario(*arguments, &return_value)
147
- scenario = @space.scenario(@double_insertion)
148
- scenario.with(*arguments).once.returns(&return_value)
149
- scenario.should be_terminal
150
- scenario
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 scenarios with duplicate Wildcard Match ArgumentExpectations" do
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
- scenario_1 = scenario {:return_1}
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
- scenario_1 = scenario {:return_1}
163
- scenario_2 = scenario {:return_2}
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 scenario's Times Called expectation is satisfied" do
170
- scenario_1 = scenario {:return_1}
171
- scenario_2 = scenario {:return_2}
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 scenarios Times Called expectation is satisfied" do
178
- scenario_1 = scenario {:return_1}
179
- scenario_2 = scenario {:return_2}
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 scenario(&return_value)
189
- scenario = @space.scenario(@double_insertion)
190
- scenario.with_any_args.once.returns(&return_value)
191
- scenario.should be_terminal
192
- scenario
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
- scenario = @space.scenario(@double_insertion)
204
- scenario.with(1, 2) {:return_value}
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
- scenario = @space.scenario(@double_insertion)
216
- scenario.with(1, 2) {:return_value}
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