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
@@ -1,24 +1,24 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInjection, "#register_scenario" do
4
+ describe DoubleInjection, "#register_double" do
5
5
  before do
6
6
  @space = Space.new
7
7
  @object = Object.new
8
8
  @method_name = :foobar
9
9
  @object.methods.should_not include(@method_name.to_s)
10
10
  @double_insertion = DoubleInjection.new(@space, @object, @method_name)
11
- def @double_insertion.scenarios
12
- @scenarios
11
+ def @double_insertion.doubles
12
+ @doubles
13
13
  end
14
14
  end
15
15
 
16
- it "adds the scenario to the scenarios list" do
17
- scenario = Double.new(@space, @double_insertion, @space.scenario_definition)
16
+ it "adds the double to the doubles list" do
17
+ double = Double.new(@space, @double_insertion, @space.double_definition)
18
18
 
19
- @double_insertion.scenarios.should_not include(scenario)
20
- @double_insertion.register_scenario scenario
21
- @double_insertion.scenarios.should include(scenario)
19
+ @double_insertion.doubles.should_not include(double)
20
+ @double_insertion.register_double double
21
+ @double_insertion.doubles.should include(double)
22
22
  end
23
23
  end
24
24
  end
@@ -10,11 +10,11 @@ module RR
10
10
  @double_insertion = @space.double_insertion(@object, @method_name)
11
11
  end
12
12
 
13
- it "verifies each scenario was met" do
14
- scenario = Double.new(@space, @double_insertion, @space.scenario_definition)
15
- @double_insertion.register_scenario scenario
13
+ it "verifies each double was met" do
14
+ double = Double.new(@space, @double_insertion, @space.double_definition)
15
+ @double_insertion.register_double double
16
16
 
17
- scenario.with(1).once.returns {nil}
17
+ double.with(1).once.returns {nil}
18
18
  proc {@double_insertion.verify}.should raise_error(Errors::TimesCalledError)
19
19
  @object.foobar(1)
20
20
  proc {@double_insertion.verify}.should_not raise_error
@@ -7,13 +7,13 @@ module RR
7
7
  end
8
8
 
9
9
  it "returns a DoubleMethodProxy when passed a subject" do
10
- scenario = creator.__send__(method_name, subject).foobar
11
- scenario.should be_instance_of(DoubleDefinition)
10
+ double = creator.__send__(method_name, subject).foobar
11
+ double.should be_instance_of(DoubleDefinition)
12
12
  end
13
13
 
14
14
  it "returns a DoubleMethodProxy when passed Kernel" do
15
- scenario = creator.__send__(method_name, Kernel).foobar
16
- scenario.should be_instance_of(DoubleDefinition)
15
+ double = creator.__send__(method_name, Kernel).foobar
16
+ double.should be_instance_of(DoubleDefinition)
17
17
  end
18
18
 
19
19
  it "raises error if passed a method name and a block" do
@@ -73,30 +73,30 @@ module RR
73
73
  end
74
74
 
75
75
  it "creates a mock Double for method when passed a second argument with rr_mock" do
76
- creates_scenario_with_method_name(
76
+ creates_double_with_method_name(
77
77
  creator.mock(subject, :foobar)
78
78
  )
79
79
  end
80
80
 
81
81
  it "sets up the DoubleDefinition to be in returns block_callback_strategy" do
82
- scenario = creator.mock(subject, :foobar)
83
- scenario.block_callback_strategy.should == :returns
82
+ double = creator.mock(subject, :foobar)
83
+ double.block_callback_strategy.should == :returns
84
84
  end
85
85
 
86
- def creates_scenario_with_method_name(scenario)
87
- scenario.with(1, 2) {:baz}
88
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
89
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
90
- scenario.argument_expectation.expected_arguments.should == [1, 2]
86
+ def creates_double_with_method_name(double)
87
+ double.with(1, 2) {:baz}
88
+ double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
89
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
90
+ double.argument_expectation.expected_arguments.should == [1, 2]
91
91
 
92
92
  subject.foobar(1, 2).should == :baz
93
93
  end
94
94
 
95
95
  def creates_mock_call_chain(creator)
96
- scenario = creator.foobar(1, 2) {:baz}
97
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
98
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
99
- scenario.argument_expectation.expected_arguments.should == [1, 2]
96
+ double = creator.foobar(1, 2) {:baz}
97
+ double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
98
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
99
+ double.argument_expectation.expected_arguments.should == [1, 2]
100
100
 
101
101
  subject.foobar(1, 2).should == :baz
102
102
  end
@@ -114,25 +114,25 @@ module RR
114
114
  end
115
115
 
116
116
  it "creates a stub Double for method when passed a second argument" do
117
- creates_scenario_with_method_name(creator.stub(subject, :foobar))
117
+ creates_double_with_method_name(creator.stub(subject, :foobar))
118
118
  end
119
119
 
120
120
  it "sets up the DoubleDefinition to be in returns block_callback_strategy" do
121
- scenario = creator.stub(subject, :foobar)
122
- scenario.block_callback_strategy.should == :returns
121
+ double = creator.stub(subject, :foobar)
122
+ double.block_callback_strategy.should == :returns
123
123
  end
124
124
 
125
- def creates_scenario_with_method_name(scenario)
126
- scenario.with(1, 2) {:baz}
127
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
128
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
125
+ def creates_double_with_method_name(double)
126
+ double.with(1, 2) {:baz}
127
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
128
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
129
129
  subject.foobar(1, 2).should == :baz
130
130
  end
131
131
 
132
132
  def creates_stub_call_chain(creator)
133
- scenario = creator.foobar(1, 2) {:baz}
134
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
135
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
133
+ double = creator.foobar(1, 2) {:baz}
134
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
135
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
136
136
  subject.foobar(1, 2).should == :baz
137
137
  end
138
138
  end
@@ -171,26 +171,26 @@ module RR
171
171
  end
172
172
 
173
173
  it "creates a mock Double for method when passed a second argument" do
174
- creates_scenario_with_method_name(creator.dont_allow(subject, :foobar))
174
+ creates_double_with_method_name(creator.dont_allow(subject, :foobar))
175
175
  end
176
176
 
177
177
  it "creates a mock Double for method when passed a second argument" do
178
- creates_scenario_with_method_name(creator.dont_call(subject, :foobar))
178
+ creates_double_with_method_name(creator.dont_call(subject, :foobar))
179
179
  end
180
180
 
181
181
  it "creates a mock Double for method when passed a second argument" do
182
- creates_scenario_with_method_name(creator.do_not_allow(subject, :foobar))
182
+ creates_double_with_method_name(creator.do_not_allow(subject, :foobar))
183
183
  end
184
184
 
185
185
  it "creates a mock Double for method when passed a second argument" do
186
- creates_scenario_with_method_name(creator.dont_allow(subject, :foobar))
186
+ creates_double_with_method_name(creator.dont_allow(subject, :foobar))
187
187
  end
188
188
 
189
- def creates_scenario_with_method_name(scenario)
190
- scenario.with(1, 2)
191
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
192
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
193
- scenario.argument_expectation.expected_arguments.should == [1, 2]
189
+ def creates_double_with_method_name(double)
190
+ double.with(1, 2)
191
+ double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
192
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
193
+ double.argument_expectation.expected_arguments.should == [1, 2]
194
194
 
195
195
  proc do
196
196
  subject.foobar(1, 2)
@@ -200,10 +200,10 @@ module RR
200
200
  end
201
201
 
202
202
  def creates_dont_allow_call_chain(creator)
203
- scenario = creator.foobar(1, 2)
204
- scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
205
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
206
- scenario.argument_expectation.expected_arguments.should == [1, 2]
203
+ double = creator.foobar(1, 2)
204
+ double.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
205
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
206
+ double.argument_expectation.expected_arguments.should == [1, 2]
207
207
 
208
208
  proc do
209
209
  subject.foobar(1, 2)
@@ -233,32 +233,32 @@ module RR
233
233
  end
234
234
 
235
235
  it "sets up the RR proxy call chain" do
236
- scenario = creator.stub.proxy(subject).foobar(1, 2) {:baz}
237
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
238
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
236
+ double = creator.stub.proxy(subject).foobar(1, 2) {:baz}
237
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
238
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
239
239
  subject.foobar(1, 2).should == :baz
240
240
  end
241
241
 
242
242
  it "sets up the RR proxy call chain" do
243
- scenario = creator.stub.proxy(subject).foobar(1, 2) {:baz}
244
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
245
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
243
+ double = creator.stub.proxy(subject).foobar(1, 2) {:baz}
244
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
245
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
246
246
  subject.foobar(1, 2).should == :baz
247
247
  end
248
248
 
249
249
  it "creates a proxy Double for method when passed a second argument" do
250
- scenario = creator.stub.proxy(subject, :foobar)
251
- scenario.with(1, 2) {:baz}
252
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
253
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
250
+ double = creator.stub.proxy(subject, :foobar)
251
+ double.with(1, 2) {:baz}
252
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
253
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
254
254
  subject.foobar(1, 2).should == :baz
255
255
  end
256
256
 
257
257
  it "creates a proxy Double for method when passed a second argument" do
258
- scenario = creator.stub.proxy(subject, :foobar)
259
- scenario.with(1, 2) {:baz}
260
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
261
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
258
+ double = creator.stub.proxy(subject, :foobar)
259
+ double.with(1, 2) {:baz}
260
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
261
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
262
262
  subject.foobar(1, 2).should == :baz
263
263
  end
264
264
 
@@ -268,12 +268,12 @@ module RR
268
268
  end
269
269
 
270
270
  args = nil
271
- scenario = creator.stub.proxy(subject, :foobar).with() do |*args|
271
+ double = creator.stub.proxy(subject, :foobar).with() do |*args|
272
272
  args = args
273
273
  end
274
274
  subject.foobar
275
275
  args.should == [:original_implementation_value]
276
- scenario.block_callback_strategy.should == :after_call
276
+ double.block_callback_strategy.should == :after_call
277
277
  end
278
278
  end
279
279
 
@@ -286,18 +286,18 @@ module RR
286
286
 
287
287
  it "sets up the RR proxy call chain" do
288
288
  klass = Class.new
289
- scenario = creator.stub.instance_of(klass).foobar(1, 2) {:baz}
290
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
291
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
289
+ double = creator.stub.instance_of(klass).foobar(1, 2) {:baz}
290
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
291
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
292
292
  klass.new.foobar(1, 2).should == :baz
293
293
  end
294
294
 
295
295
  it "creates a proxy Double for method when passed a second argument" do
296
296
  klass = Class.new
297
- scenario = creator.stub.instance_of(klass, :foobar)
298
- scenario.with(1, 2) {:baz}
299
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
300
- scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
297
+ double = creator.stub.instance_of(klass, :foobar)
298
+ double.with(1, 2) {:baz}
299
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
300
+ double.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
301
301
  klass.new.foobar(1, 2).should == :baz
302
302
  end
303
303
  end
@@ -387,7 +387,7 @@ module RR
387
387
  proc {subject.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
388
388
  end
389
389
 
390
- it "sets after_call on the scenario when passed a block" do
390
+ it "sets after_call on the double when passed a block" do
391
391
  real_value = Object.new
392
392
  (
393
393
  class << subject;
@@ -412,7 +412,7 @@ module RR
412
412
  creator.proxy
413
413
  end
414
414
 
415
- it "sets up a scenario with passed in arguments" do
415
+ it "sets up a double with passed in arguments" do
416
416
  def subject.foobar(*args)
417
417
  ; :baz;
418
418
  end
@@ -432,7 +432,7 @@ module RR
432
432
  end
433
433
  end
434
434
 
435
- it "sets after_call on the scenario when passed a block" do
435
+ it "sets after_call on the double when passed a block" do
436
436
  real_value = Object.new
437
437
  (
438
438
  class << subject;
@@ -7,8 +7,8 @@ describe DoubleDefinition, :shared => true do
7
7
  @object = Object.new
8
8
  add_original_method
9
9
  @double_insertion = @space.double_insertion(@object, :foobar)
10
- @scenario = @space.scenario(@double_insertion)
11
- @definition = @scenario.definition
10
+ @double = @space.double(@double_insertion)
11
+ @definition = @double.definition
12
12
  end
13
13
 
14
14
  def add_original_method
@@ -454,14 +454,14 @@ end
454
454
  describe DoubleDefinition, "#ordered", :shared => true do
455
455
  it_should_behave_like "RR::DoubleDefinition"
456
456
 
457
- it "adds itself to the ordered scenarios list" do
457
+ it "adds itself to the ordered doubles list" do
458
458
  @definition.ordered
459
- @space.ordered_scenarios.should include(@scenario)
459
+ @space.ordered_doubles.should include(@double)
460
460
  end
461
461
 
462
462
  it "does not double_insertion add itself" do
463
463
  @definition.ordered
464
- @space.ordered_scenarios.should == [@scenario]
464
+ @space.ordered_doubles.should == [@double]
465
465
  end
466
466
 
467
467
  it "sets ordered? to true" do
@@ -469,7 +469,7 @@ describe DoubleDefinition, "#ordered", :shared => true do
469
469
  end
470
470
 
471
471
  it "raises error when there is no Double" do
472
- @definition.scenario = nil
472
+ @definition.double = nil
473
473
  proc do
474
474
  @definition.ordered
475
475
  end.should raise_error(
@@ -684,9 +684,9 @@ describe DoubleDefinition, "#implemented_by_original_method" do
684
684
  end
685
685
  end
686
686
  double_insertion = @space.double_insertion(@object, :does_not_exist)
687
- scenario = @space.scenario(double_insertion)
688
- scenario.with_any_args
689
- scenario.implemented_by_original_method
687
+ double = @space.double(double_insertion)
688
+ double.with_any_args
689
+ double.implemented_by_original_method
690
690
 
691
691
  return_value = @object.does_not_exist(1, 2)
692
692
  return_value.should == "method_missing for does_not_exist([1, 2])"
@@ -15,7 +15,7 @@ module RR
15
15
  before(:each) do
16
16
  @space = Space.new
17
17
  @subject = Object.new
18
- @creator = space.scenario_creator
18
+ @creator = space.double_creator
19
19
  creator.mock
20
20
  end
21
21
 
@@ -27,13 +27,13 @@ module RR
27
27
 
28
28
  it "clears out all methods from proxy" do
29
29
  proxy_subclass = Class.new(DoubleMethodProxy) do
30
- def i_should_be_a_scenario
30
+ def i_should_be_a_double
31
31
  end
32
32
  end
33
- proxy_subclass.instance_methods.should include('i_should_be_a_scenario')
33
+ proxy_subclass.instance_methods.should include('i_should_be_a_double')
34
34
 
35
35
  proxy = proxy_subclass.new(space, creator, subject)
36
- proxy.i_should_be_a_scenario.should be_instance_of(DoubleDefinition)
36
+ proxy.i_should_be_a_double.should be_instance_of(DoubleDefinition)
37
37
  end
38
38
  end
39
39
 
@@ -57,13 +57,13 @@ module RR
57
57
 
58
58
  it "clears out all methods from proxy" do
59
59
  proxy_subclass = Class.new(DoubleMethodProxy) do
60
- def i_should_be_a_scenario
60
+ def i_should_be_a_double
61
61
  end
62
62
  end
63
- proxy_subclass.instance_methods.should include('i_should_be_a_scenario')
63
+ proxy_subclass.instance_methods.should include('i_should_be_a_double')
64
64
 
65
65
  proxy_subclass.new(space, creator, subject) do |m|
66
- m.i_should_be_a_scenario.should be_instance_of(DoubleDefinition)
66
+ m.i_should_be_a_double.should be_instance_of(DoubleDefinition)
67
67
  end
68
68
  end
69
69
  end
@@ -2,7 +2,7 @@ require "spec/spec_helper"
2
2
 
3
3
  module RR
4
4
  describe Double do
5
- attr_reader :space, :object, :double_insertion, :scenario
5
+ attr_reader :space, :object, :double_insertion, :double
6
6
  before do
7
7
  @space = Space.new
8
8
  @object = Object.new
@@ -10,38 +10,38 @@ module RR
10
10
  [b, a]
11
11
  end
12
12
  @double_insertion = space.double_insertion(object, :foobar)
13
- @scenario = space.scenario(double_insertion)
13
+ @double = space.double(double_insertion)
14
14
  end
15
15
 
16
16
  describe "#with" do
17
17
  it "returns DoubleDefinition" do
18
- scenario.with(1).should === scenario.definition
18
+ double.with(1).should === double.definition
19
19
  end
20
20
 
21
21
  it "sets an ArgumentEqualityExpectation" do
22
- scenario.with(1)
23
- scenario.should be_exact_match(1)
24
- scenario.should_not be_exact_match(2)
22
+ double.with(1)
23
+ double.should be_exact_match(1)
24
+ double.should_not be_exact_match(2)
25
25
  end
26
26
 
27
27
  it "sets return value when block passed in" do
28
- scenario.with(1) {:return_value}
28
+ double.with(1) {:return_value}
29
29
  object.foobar(1).should == :return_value
30
30
  end
31
31
  end
32
32
 
33
33
  describe "#with_any_args" do
34
34
  before do
35
- scenario.with_any_args {:return_value}
35
+ double.with_any_args {:return_value}
36
36
  end
37
37
 
38
38
  it "returns DoubleDefinition" do
39
- scenario.with_no_args.should === scenario.definition
39
+ double.with_no_args.should === double.definition
40
40
  end
41
41
 
42
42
  it "sets an AnyArgumentExpectation" do
43
- scenario.should_not be_exact_match(1)
44
- scenario.should be_wildcard_match(1)
43
+ double.should_not be_exact_match(1)
44
+ double.should be_wildcard_match(1)
45
45
  end
46
46
 
47
47
  it "sets return value when block passed in" do
@@ -51,15 +51,15 @@ module RR
51
51
 
52
52
  describe "#with_no_args" do
53
53
  before do
54
- scenario.with_no_args {:return_value}
54
+ double.with_no_args {:return_value}
55
55
  end
56
56
 
57
57
  it "returns DoubleDefinition" do
58
- scenario.with_no_args.should === scenario.definition
58
+ double.with_no_args.should === double.definition
59
59
  end
60
60
 
61
61
  it "sets an ArgumentEqualityExpectation with no arguments" do
62
- scenario.argument_expectation.should == Expectations::ArgumentEqualityExpectation.new()
62
+ double.argument_expectation.should == Expectations::ArgumentEqualityExpectation.new()
63
63
  end
64
64
 
65
65
  it "sets return value when block passed in" do
@@ -69,82 +69,82 @@ module RR
69
69
 
70
70
  describe "#never" do
71
71
  it "returns DoubleDefinition" do
72
- scenario.never.should === scenario.definition
72
+ double.never.should === double.definition
73
73
  end
74
74
 
75
75
  it "sets up a Times Called Expectation with 0" do
76
- scenario.never
77
- proc {scenario.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
76
+ double.never
77
+ proc {double.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
78
78
  end
79
79
 
80
80
  it "sets return value when block passed in" do
81
- scenario.with_any_args.never
82
- proc {scenario.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
81
+ double.with_any_args.never
82
+ proc {double.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
83
83
  end
84
84
  end
85
85
 
86
86
  describe "#once" do
87
87
  it "returns DoubleDefinition" do
88
- scenario.once.should === scenario.definition
88
+ double.once.should === double.definition
89
89
  end
90
90
 
91
91
  it "sets up a Times Called Expectation with 1" do
92
- scenario.once
93
- scenario.call(double_insertion)
94
- proc {scenario.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
92
+ double.once
93
+ double.call(double_insertion)
94
+ proc {double.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
95
95
  end
96
96
 
97
97
  it "sets return value when block passed in" do
98
- scenario.with_any_args.once {:return_value}
98
+ double.with_any_args.once {:return_value}
99
99
  object.foobar.should == :return_value
100
100
  end
101
101
  end
102
102
 
103
103
  describe "#twice" do
104
104
  it "returns DoubleDefinition" do
105
- scenario.twice.should === scenario.definition
105
+ double.twice.should === double.definition
106
106
  end
107
107
 
108
108
  it "sets up a Times Called Expectation with 2" do
109
- scenario.twice
110
- scenario.call(double_insertion)
111
- scenario.call(double_insertion)
112
- proc {scenario.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
109
+ double.twice
110
+ double.call(double_insertion)
111
+ double.call(double_insertion)
112
+ proc {double.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
113
113
  end
114
114
 
115
115
  it "sets return value when block passed in" do
116
- scenario.with_any_args.twice {:return_value}
116
+ double.with_any_args.twice {:return_value}
117
117
  object.foobar.should == :return_value
118
118
  end
119
119
  end
120
120
 
121
121
  describe "#at_least" do
122
122
  it "returns DoubleDefinition" do
123
- scenario.with_any_args.at_least(2).should === scenario.definition
123
+ double.with_any_args.at_least(2).should === double.definition
124
124
  end
125
125
 
126
126
  it "sets up a AtLeastMatcher with 2" do
127
- scenario.at_least(2)
128
- scenario.definition.times_matcher.should == TimesCalledMatchers::AtLeastMatcher.new(2)
127
+ double.at_least(2)
128
+ double.definition.times_matcher.should == TimesCalledMatchers::AtLeastMatcher.new(2)
129
129
  end
130
130
 
131
131
  it "sets return value when block passed in" do
132
- scenario.with_any_args.at_least(2) {:return_value}
132
+ double.with_any_args.at_least(2) {:return_value}
133
133
  object.foobar.should == :return_value
134
134
  end
135
135
  end
136
136
 
137
137
  describe "#at_most" do
138
138
  it "returns DoubleDefinition" do
139
- scenario.with_any_args.at_most(2).should === scenario.definition
139
+ double.with_any_args.at_most(2).should === double.definition
140
140
  end
141
141
 
142
142
  it "sets up a Times Called Expectation with 1" do
143
- scenario.at_most(2)
144
- scenario.call(double_insertion)
145
- scenario.call(double_insertion)
143
+ double.at_most(2)
144
+ double.call(double_insertion)
145
+ double.call(double_insertion)
146
146
  proc do
147
- scenario.call(double_insertion)
147
+ double.call(double_insertion)
148
148
  end.should raise_error(
149
149
  Errors::TimesCalledError,
150
150
  "foobar()\nCalled 3 times.\nExpected at most 2 times."
@@ -152,89 +152,89 @@ module RR
152
152
  end
153
153
 
154
154
  it "sets return value when block passed in" do
155
- scenario.with_any_args.at_most(2) {:return_value}
155
+ double.with_any_args.at_most(2) {:return_value}
156
156
  object.foobar.should == :return_value
157
157
  end
158
158
  end
159
159
 
160
160
  describe "#times" do
161
161
  it "returns DoubleDefinition" do
162
- scenario.times(3).should === scenario.definition
162
+ double.times(3).should === double.definition
163
163
  end
164
164
 
165
165
  it "sets up a Times Called Expectation with passed in times" do
166
- scenario.times(3)
167
- scenario.call(double_insertion)
168
- scenario.call(double_insertion)
169
- scenario.call(double_insertion)
170
- proc {scenario.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
166
+ double.times(3)
167
+ double.call(double_insertion)
168
+ double.call(double_insertion)
169
+ double.call(double_insertion)
170
+ proc {double.call(double_insertion)}.should raise_error(Errors::TimesCalledError)
171
171
  end
172
172
 
173
173
  it "sets return value when block passed in" do
174
- scenario.with_any_args.times(3) {:return_value}
174
+ double.with_any_args.times(3) {:return_value}
175
175
  object.foobar.should == :return_value
176
176
  end
177
177
  end
178
178
 
179
179
  describe "#any_number_of_times" do
180
180
  it "returns DoubleDefinition" do
181
- scenario.any_number_of_times.should === scenario.definition
181
+ double.any_number_of_times.should === double.definition
182
182
  end
183
183
 
184
184
  it "sets up a Times Called Expectation with AnyTimes matcher" do
185
- scenario.any_number_of_times
186
- scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
185
+ double.any_number_of_times
186
+ double.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
187
187
  end
188
188
 
189
189
  it "sets return value when block passed in" do
190
- scenario.with_any_args.any_number_of_times {:return_value}
190
+ double.with_any_args.any_number_of_times {:return_value}
191
191
  object.foobar.should == :return_value
192
192
  end
193
193
  end
194
194
 
195
195
  describe "#ordered" do
196
- it "adds itself to the ordered scenarios list" do
197
- scenario.ordered
198
- space.ordered_scenarios.should include(scenario)
196
+ it "adds itself to the ordered doubles list" do
197
+ double.ordered
198
+ space.ordered_doubles.should include(double)
199
199
  end
200
200
 
201
201
  it "does not double_insertion add itself" do
202
- scenario.ordered
203
- scenario.ordered
204
- space.ordered_scenarios.should == [scenario ]
202
+ double.ordered
203
+ double.ordered
204
+ space.ordered_doubles.should == [double ]
205
205
  end
206
206
 
207
207
  it "sets ordered? to true" do
208
- scenario.ordered
209
- scenario.should be_ordered
208
+ double.ordered
209
+ double.should be_ordered
210
210
  end
211
211
 
212
212
  it "sets return value when block passed in" do
213
- scenario.with_any_args.once.ordered {:return_value}
213
+ double.with_any_args.once.ordered {:return_value}
214
214
  object.foobar.should == :return_value
215
215
  end
216
216
  end
217
217
 
218
218
  describe "#ordered?" do
219
219
  it "defaults to false" do
220
- scenario.should_not be_ordered
220
+ double.should_not be_ordered
221
221
  end
222
222
  end
223
223
 
224
224
  describe "#yields" do
225
225
  it "returns DoubleDefinition" do
226
- scenario.yields(:baz).should === scenario.definition
226
+ double.yields(:baz).should === double.definition
227
227
  end
228
228
 
229
229
  it "yields the passed in argument to the call block when there is no returns value set" do
230
- scenario.with_any_args.yields(:baz)
230
+ double.with_any_args.yields(:baz)
231
231
  passed_in_block_arg = nil
232
232
  object.foobar {|arg| passed_in_block_arg = arg}.should == nil
233
233
  passed_in_block_arg.should == :baz
234
234
  end
235
235
 
236
236
  it "yields the passed in argument to the call block when there is a no returns value set" do
237
- scenario.with_any_args.yields(:baz).returns(:return_value)
237
+ double.with_any_args.yields(:baz).returns(:return_value)
238
238
 
239
239
  passed_in_block_arg = nil
240
240
  object.foobar {|arg| passed_in_block_arg = arg}.should == :return_value
@@ -242,41 +242,41 @@ module RR
242
242
  end
243
243
 
244
244
  it "sets return value when block passed in" do
245
- scenario.with_any_args.yields {:return_value}
245
+ double.with_any_args.yields {:return_value}
246
246
  object.foobar {}.should == :return_value
247
247
  end
248
248
  end
249
249
 
250
250
  describe "#after_call" do
251
251
  it "returns DoubleDefinition" do
252
- scenario.after_call {}.should === scenario.definition
252
+ double.after_call {}.should === double.definition
253
253
  end
254
254
 
255
255
  it "sends return value of Double implementation to after_call" do
256
256
  return_value = {}
257
- scenario.returns(return_value).after_call do |value|
257
+ double.returns(return_value).after_call do |value|
258
258
  value[:foo] = :bar
259
259
  value
260
260
  end
261
261
 
262
- actual_value = scenario.call(double_insertion)
262
+ actual_value = double.call(double_insertion)
263
263
  actual_value.should === return_value
264
264
  actual_value.should == {:foo => :bar}
265
265
  end
266
266
 
267
267
  it "receives the return value in the after_call callback" do
268
268
  return_value = :returns_value
269
- scenario.returns(return_value).after_call do |value|
269
+ double.returns(return_value).after_call do |value|
270
270
  :after_call_value
271
271
  end
272
272
 
273
- actual_value = scenario.call(double_insertion)
273
+ actual_value = double.call(double_insertion)
274
274
  actual_value.should == :after_call_value
275
275
  end
276
276
 
277
277
  it "allows after_call to mock the return value" do
278
278
  return_value = Object.new
279
- scenario.with_any_args.returns(return_value).after_call do |value|
279
+ double.with_any_args.returns(return_value).after_call do |value|
280
280
  mock(value).inner_method(1) {:baz}
281
281
  value
282
282
  end
@@ -286,66 +286,66 @@ module RR
286
286
 
287
287
  it "raises an error when not passed a block" do
288
288
  proc do
289
- scenario.after_call
289
+ double.after_call
290
290
  end.should raise_error(ArgumentError, "after_call expects a block")
291
291
  end
292
292
  end
293
293
 
294
294
  describe "#returns" do
295
295
  it "returns DoubleDefinition" do
296
- scenario.returns {:baz}.should === scenario.definition
297
- scenario.returns(:baz).should === scenario.definition
296
+ double.returns {:baz}.should === double.definition
297
+ double.returns(:baz).should === double.definition
298
298
  end
299
299
 
300
300
  it "sets the value of the method when passed a block" do
301
- scenario.returns {:baz}
302
- scenario.call(double_insertion).should == :baz
301
+ double.returns {:baz}
302
+ double.call(double_insertion).should == :baz
303
303
  end
304
304
 
305
305
  it "sets the value of the method when passed an argument" do
306
- scenario.returns(:baz)
307
- scenario.call(double_insertion).should == :baz
306
+ double.returns(:baz)
307
+ double.call(double_insertion).should == :baz
308
308
  end
309
309
 
310
310
  it "returns false when passed false" do
311
- scenario.returns(false)
312
- scenario.call(double_insertion).should == false
311
+ double.returns(false)
312
+ double.call(double_insertion).should == false
313
313
  end
314
314
 
315
315
  it "raises an error when both argument and block is passed in" do
316
316
  proc do
317
- scenario.returns(:baz) {:another}
317
+ double.returns(:baz) {:another}
318
318
  end.should raise_error(ArgumentError, "returns cannot accept both an argument and a block")
319
319
  end
320
320
  end
321
321
 
322
322
  describe "#implemented_by" do
323
323
  it "returns the DoubleDefinition" do
324
- scenario.implemented_by(proc{:baz}).should === scenario.definition
324
+ double.implemented_by(proc{:baz}).should === double.definition
325
325
  end
326
326
 
327
327
  it "sets the implementation to the passed in proc" do
328
- scenario.implemented_by(proc{:baz})
329
- scenario.call(double_insertion).should == :baz
328
+ double.implemented_by(proc{:baz})
329
+ double.call(double_insertion).should == :baz
330
330
  end
331
331
 
332
332
  it "sets the implementation to the passed in method" do
333
333
  def object.foobar(a, b)
334
334
  [b, a]
335
335
  end
336
- scenario.implemented_by(object.method(:foobar))
337
- scenario.call(double_insertion, 1, 2).should == [2, 1]
336
+ double.implemented_by(object.method(:foobar))
337
+ double.call(double_insertion, 1, 2).should == [2, 1]
338
338
  end
339
339
  end
340
340
 
341
341
  describe "#implemented_by_original_method" do
342
342
  it "returns the DoubleDefinition object" do
343
- scenario.implemented_by_original_method.should === scenario.definition
343
+ double.implemented_by_original_method.should === double.definition
344
344
  end
345
345
 
346
346
  it "sets the implementation to the original method" do
347
- scenario.implemented_by_original_method
348
- scenario.call(double_insertion, 1, 2).should == [2, 1]
347
+ double.implemented_by_original_method
348
+ double.call(double_insertion, 1, 2).should == [2, 1]
349
349
  end
350
350
 
351
351
  it "calls methods when respond_to? is true and methods does not contain original method" do
@@ -366,9 +366,9 @@ module RR
366
366
  end
367
367
 
368
368
  double_insertion = space.double_insertion(object, :foobar)
369
- scenario = space.scenario(double_insertion)
370
- scenario.with_any_args
371
- scenario.implemented_by_original_method
369
+ double = space.double(double_insertion)
370
+ double.with_any_args
371
+ double.implemented_by_original_method
372
372
 
373
373
  object.foobar(1, 2).should == [2, 1]
374
374
  end
@@ -380,9 +380,9 @@ module RR
380
380
  end
381
381
  end
382
382
  double_insertion = space.double_insertion(object, :does_not_exist)
383
- scenario = space.scenario(double_insertion)
384
- scenario.with_any_args
385
- scenario.implemented_by_original_method
383
+ double = space.double(double_insertion)
384
+ double.with_any_args
385
+ double.implemented_by_original_method
386
386
 
387
387
  return_value = object.does_not_exist(1, 2)
388
388
  return_value.should == "method_missing for does_not_exist([1, 2])"
@@ -391,40 +391,40 @@ module RR
391
391
 
392
392
  describe "#call implemented by a proc" do
393
393
  it "calls the return proc when implemented by a proc" do
394
- scenario.returns {|arg| "returning #{arg}"}
395
- scenario.call(double_insertion, :foobar).should == "returning foobar"
394
+ double.returns {|arg| "returning #{arg}"}
395
+ double.call(double_insertion, :foobar).should == "returning foobar"
396
396
  end
397
397
 
398
398
  it "calls and returns the after_call when after_call is set" do
399
- scenario.returns {|arg| "returning #{arg}"}.after_call do |value|
399
+ double.returns {|arg| "returning #{arg}"}.after_call do |value|
400
400
  "#{value} after call"
401
401
  end
402
- scenario.call(double_insertion, :foobar).should == "returning foobar after call"
402
+ double.call(double_insertion, :foobar).should == "returning foobar after call"
403
403
  end
404
404
 
405
405
  it "returns nil when to returns is not set" do
406
- scenario.call(double_insertion).should be_nil
406
+ double.call(double_insertion).should be_nil
407
407
  end
408
408
 
409
409
  it "works when times_called is not set" do
410
- scenario.returns {:value}
411
- scenario.call(double_insertion)
410
+ double.returns {:value}
411
+ double.call(double_insertion)
412
412
  end
413
413
 
414
414
  it "verifes the times_called does not exceed the TimesCalledExpectation" do
415
- scenario.times(2).returns {:value}
415
+ double.times(2).returns {:value}
416
416
 
417
- scenario.call(double_insertion, :foobar)
418
- scenario.call(double_insertion, :foobar)
419
- proc {scenario.call(double_insertion, :foobar)}.should raise_error(Errors::TimesCalledError)
417
+ double.call(double_insertion, :foobar)
418
+ double.call(double_insertion, :foobar)
419
+ proc {double.call(double_insertion, :foobar)}.should raise_error(Errors::TimesCalledError)
420
420
  end
421
421
 
422
422
  it "raises DoubleOrderError when ordered and called out of order" do
423
- scenario1 = scenario
424
- scenario2 = space.scenario(double_insertion)
423
+ double1 = double
424
+ double2 = space.double(double_insertion)
425
425
 
426
- scenario1.with(1).returns {:return_1}.ordered.once
427
- scenario2.with(2).returns {:return_2}.ordered.once
426
+ double1.with(1).returns {:return_1}.ordered.once
427
+ double2.with(2).returns {:return_2}.ordered.once
428
428
 
429
429
  proc do
430
430
  object.foobar(2)
@@ -436,59 +436,59 @@ module RR
436
436
  )
437
437
  end
438
438
 
439
- it "dispatches to Space#verify_ordered_scenario when ordered" do
440
- verify_ordered_scenario_called = false
441
- passed_in_scenario = nil
442
- space.method(:verify_ordered_scenario).arity.should == 1
439
+ it "dispatches to Space#verify_ordered_double when ordered" do
440
+ verify_ordered_double_called = false
441
+ passed_in_double = nil
442
+ space.method(:verify_ordered_double).arity.should == 1
443
443
  (
444
444
  class << space;
445
445
  self;
446
446
  end).class_eval do
447
- define_method :verify_ordered_scenario do |scenario|
448
- passed_in_scenario = scenario
449
- verify_ordered_scenario_called = true
447
+ define_method :verify_ordered_double do |double|
448
+ passed_in_double = double
449
+ verify_ordered_double_called = true
450
450
  end
451
451
  end
452
452
 
453
- scenario.returns {:value}.ordered
454
- scenario.call(double_insertion, :foobar)
455
- verify_ordered_scenario_called.should be_true
456
- passed_in_scenario.should === scenario
453
+ double.returns {:value}.ordered
454
+ double.call(double_insertion, :foobar)
455
+ verify_ordered_double_called.should be_true
456
+ passed_in_double.should === double
457
457
  end
458
458
 
459
- it "does not dispatche to Space#verify_ordered_scenario when not ordered" do
460
- verify_ordered_scenario_called = false
461
- space.method(:verify_ordered_scenario).arity.should == 1
459
+ it "does not dispatche to Space#verify_ordered_double when not ordered" do
460
+ verify_ordered_double_called = false
461
+ space.method(:verify_ordered_double).arity.should == 1
462
462
  (
463
463
  class << space;
464
464
  self;
465
465
  end).class_eval do
466
- define_method :verify_ordered_scenario do |scenario|
467
- verify_ordered_scenario_called = true
466
+ define_method :verify_ordered_double do |double|
467
+ verify_ordered_double_called = true
468
468
  end
469
469
  end
470
470
 
471
- scenario.returns {:value}
472
- scenario.call(double_insertion, :foobar)
473
- verify_ordered_scenario_called.should be_false
471
+ double.returns {:value}
472
+ double.call(double_insertion, :foobar)
473
+ verify_ordered_double_called.should be_false
474
474
  end
475
475
 
476
476
  it "does not add block argument if no block passed in" do
477
- scenario.with(1, 2).returns {|*args| args}
477
+ double.with(1, 2).returns {|*args| args}
478
478
 
479
479
  args = object.foobar(1, 2)
480
480
  args.should == [1, 2]
481
481
  end
482
482
 
483
483
  it "makes the block the last argument" do
484
- scenario.with(1, 2).returns {|a, b, blk| blk}
484
+ double.with(1, 2).returns {|a, b, blk| blk}
485
485
 
486
486
  block = object.foobar(1, 2) {|a, b| [b, a]}
487
487
  block.call(3, 4).should == [4, 3]
488
488
  end
489
489
 
490
490
  it "raises ArgumentError when yields was called and no block passed in" do
491
- scenario.with(1, 2).yields(55)
491
+ double.with(1, 2).yields(55)
492
492
 
493
493
  proc do
494
494
  object.foobar(1, 2)
@@ -502,7 +502,7 @@ module RR
502
502
  yield(a, b)
503
503
  end
504
504
 
505
- scenario.with(1, 2).implemented_by(object.method(:foobar))
505
+ double.with(1, 2).implemented_by(object.method(:foobar))
506
506
 
507
507
  object.foobar(1, 2) {|a, b| [b, a]}.should == [2, 1]
508
508
  end
@@ -510,144 +510,144 @@ module RR
510
510
 
511
511
  describe "#exact_match?" do
512
512
  it "returns false when no expectation set" do
513
- scenario.should_not be_exact_match()
514
- scenario.should_not be_exact_match(nil)
515
- scenario.should_not be_exact_match(Object.new)
516
- scenario.should_not be_exact_match(1, 2, 3)
513
+ double.should_not be_exact_match()
514
+ double.should_not be_exact_match(nil)
515
+ double.should_not be_exact_match(Object.new)
516
+ double.should_not be_exact_match(1, 2, 3)
517
517
  end
518
518
 
519
519
  it "returns false when arguments are not an exact match" do
520
- scenario.with(1, 2, 3)
521
- scenario.should_not be_exact_match(1, 2)
522
- scenario.should_not be_exact_match(1)
523
- scenario.should_not be_exact_match()
524
- scenario.should_not be_exact_match("does not match")
520
+ double.with(1, 2, 3)
521
+ double.should_not be_exact_match(1, 2)
522
+ double.should_not be_exact_match(1)
523
+ double.should_not be_exact_match()
524
+ double.should_not be_exact_match("does not match")
525
525
  end
526
526
 
527
527
  it "returns true when arguments are an exact match" do
528
- scenario.with(1, 2, 3)
529
- scenario.should be_exact_match(1, 2, 3)
528
+ double.with(1, 2, 3)
529
+ double.should be_exact_match(1, 2, 3)
530
530
  end
531
531
  end
532
532
 
533
533
  describe "#wildcard_match?" do
534
534
  it "returns false when no expectation set" do
535
- scenario.should_not be_wildcard_match()
536
- scenario.should_not be_wildcard_match(nil)
537
- scenario.should_not be_wildcard_match(Object.new)
538
- scenario.should_not be_wildcard_match(1, 2, 3)
535
+ double.should_not be_wildcard_match()
536
+ double.should_not be_wildcard_match(nil)
537
+ double.should_not be_wildcard_match(Object.new)
538
+ double.should_not be_wildcard_match(1, 2, 3)
539
539
  end
540
540
 
541
541
  it "returns true when arguments are an exact match" do
542
- scenario.with(1, 2, 3)
543
- scenario.should be_wildcard_match(1, 2, 3)
544
- scenario.should_not be_wildcard_match(1, 2)
545
- scenario.should_not be_wildcard_match(1)
546
- scenario.should_not be_wildcard_match()
547
- scenario.should_not be_wildcard_match("does not match")
542
+ double.with(1, 2, 3)
543
+ double.should be_wildcard_match(1, 2, 3)
544
+ double.should_not be_wildcard_match(1, 2)
545
+ double.should_not be_wildcard_match(1)
546
+ double.should_not be_wildcard_match()
547
+ double.should_not be_wildcard_match("does not match")
548
548
  end
549
549
 
550
550
  it "returns true when with_any_args" do
551
- scenario.with_any_args
551
+ double.with_any_args
552
552
 
553
- scenario.should be_wildcard_match(1, 2, 3)
554
- scenario.should be_wildcard_match(1, 2)
555
- scenario.should be_wildcard_match(1)
556
- scenario.should be_wildcard_match()
557
- scenario.should be_wildcard_match("does not match")
553
+ double.should be_wildcard_match(1, 2, 3)
554
+ double.should be_wildcard_match(1, 2)
555
+ double.should be_wildcard_match(1)
556
+ double.should be_wildcard_match()
557
+ double.should be_wildcard_match("does not match")
558
558
  end
559
559
  end
560
560
 
561
561
  describe "#attempt?" do
562
562
  it "returns true when TimesCalledExpectation#attempt? is true" do
563
- scenario.with(1, 2, 3).twice
564
- scenario.call(double_insertion, 1, 2, 3)
565
- scenario.times_called_expectation.should be_attempt
566
- scenario.should be_attempt
563
+ double.with(1, 2, 3).twice
564
+ double.call(double_insertion, 1, 2, 3)
565
+ double.times_called_expectation.should be_attempt
566
+ double.should be_attempt
567
567
  end
568
568
 
569
569
  it "returns false when TimesCalledExpectation#attempt? is true" do
570
- scenario.with(1, 2, 3).twice
571
- scenario.call(double_insertion, 1, 2, 3)
572
- scenario.call(double_insertion, 1, 2, 3)
573
- scenario.times_called_expectation.should_not be_attempt
574
- scenario.should_not be_attempt
570
+ double.with(1, 2, 3).twice
571
+ double.call(double_insertion, 1, 2, 3)
572
+ double.call(double_insertion, 1, 2, 3)
573
+ double.times_called_expectation.should_not be_attempt
574
+ double.should_not be_attempt
575
575
  end
576
576
 
577
577
  it "returns true when there is no Times Called expectation" do
578
- scenario.with(1, 2, 3)
579
- scenario.definition.times_matcher.should be_nil
580
- scenario.should be_attempt
578
+ double.with(1, 2, 3)
579
+ double.definition.times_matcher.should be_nil
580
+ double.should be_attempt
581
581
  end
582
582
  end
583
583
 
584
584
  describe "#verify" do
585
585
  it "verifies that times called expectation was met" do
586
- scenario.twice.returns {:return_value}
586
+ double.twice.returns {:return_value}
587
587
 
588
- proc {scenario.verify}.should raise_error(Errors::TimesCalledError)
589
- scenario.call(double_insertion)
590
- proc {scenario.verify}.should raise_error(Errors::TimesCalledError)
591
- scenario.call(double_insertion)
588
+ proc {double.verify}.should raise_error(Errors::TimesCalledError)
589
+ double.call(double_insertion)
590
+ proc {double.verify}.should raise_error(Errors::TimesCalledError)
591
+ double.call(double_insertion)
592
592
 
593
- proc {scenario.verify}.should_not raise_error
593
+ proc {double.verify}.should_not raise_error
594
594
  end
595
595
 
596
596
  it "does not raise an error when there is no times called expectation" do
597
- proc {scenario.verify}.should_not raise_error
598
- scenario.call(double_insertion)
599
- proc {scenario.verify}.should_not raise_error
600
- scenario.call(double_insertion)
601
- proc {scenario.verify}.should_not raise_error
597
+ proc {double.verify}.should_not raise_error
598
+ double.call(double_insertion)
599
+ proc {double.verify}.should_not raise_error
600
+ double.call(double_insertion)
601
+ proc {double.verify}.should_not raise_error
602
602
  end
603
603
  end
604
604
 
605
605
  describe "#terminal?" do
606
606
  it "returns true when times_called_expectation's terminal? is true" do
607
- scenario.once
608
- scenario.times_called_expectation.should be_terminal
609
- scenario.should be_terminal
607
+ double.once
608
+ double.times_called_expectation.should be_terminal
609
+ double.should be_terminal
610
610
  end
611
611
 
612
612
  it "returns false when times_called_expectation's terminal? is false" do
613
- scenario.any_number_of_times
614
- scenario.times_called_expectation.should_not be_terminal
615
- scenario.should_not be_terminal
613
+ double.any_number_of_times
614
+ double.times_called_expectation.should_not be_terminal
615
+ double.should_not be_terminal
616
616
  end
617
617
 
618
618
  it "returns false when there is no times_matcher" do
619
- scenario.definition.times_matcher.should be_nil
620
- scenario.should_not be_terminal
619
+ double.definition.times_matcher.should be_nil
620
+ double.should_not be_terminal
621
621
  end
622
622
  end
623
623
 
624
624
  describe "#method_name" do
625
625
  it "returns the DoubleInjection's method_name" do
626
626
  double_insertion.method_name.should == :foobar
627
- scenario.method_name.should == :foobar
627
+ double.method_name.should == :foobar
628
628
  end
629
629
  end
630
630
 
631
631
  describe "#expected_arguments" do
632
632
  it "returns argument expectation's expected_arguments when there is a argument expectation" do
633
- scenario.with(1, 2)
634
- scenario.expected_arguments.should == [1, 2]
633
+ double.with(1, 2)
634
+ double.expected_arguments.should == [1, 2]
635
635
  end
636
636
 
637
637
  it "returns an empty array when there is no argument expectation" do
638
- scenario.argument_expectation.should be_nil
639
- scenario.expected_arguments.should == []
638
+ double.argument_expectation.should be_nil
639
+ double.expected_arguments.should == []
640
640
  end
641
641
  end
642
642
 
643
643
  describe "#formatted_name" do
644
644
  it "renders the formatted name of the Double with no arguments" do
645
- scenario.formatted_name.should == "foobar()"
645
+ double.formatted_name.should == "foobar()"
646
646
  end
647
647
 
648
648
  it "renders the formatted name of the Double with arguments" do
649
- scenario.with(1, 2)
650
- scenario.formatted_name.should == "foobar(1, 2)"
649
+ double.with(1, 2)
650
+ double.formatted_name.should == "foobar(1, 2)"
651
651
  end
652
652
  end
653
653
  end