rr 0.1.0

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.
Files changed (65) hide show
  1. data/CHANGES +1 -0
  2. data/README +45 -0
  3. data/Rakefile +60 -0
  4. data/examples/environment_fixture_setup.rb +7 -0
  5. data/examples/example_helper.rb +8 -0
  6. data/examples/example_suite.rb +45 -0
  7. data/examples/high_level_example.rb +132 -0
  8. data/examples/rr/do_not_allow_creator_example.rb +90 -0
  9. data/examples/rr/double_bind_example.rb +32 -0
  10. data/examples/rr/double_dispatching_example.rb +167 -0
  11. data/examples/rr/double_example.rb +67 -0
  12. data/examples/rr/double_register_scenario_example.rb +25 -0
  13. data/examples/rr/double_reset_example.rb +60 -0
  14. data/examples/rr/double_verify_example.rb +24 -0
  15. data/examples/rr/expectations/any_argument_expectation_example.rb +43 -0
  16. data/examples/rr/expectations/anything_argument_equality_expectation_example.rb +39 -0
  17. data/examples/rr/expectations/argument_equality_expectation_example.rb +53 -0
  18. data/examples/rr/expectations/boolean_argument_equality_expectation_example.rb +49 -0
  19. data/examples/rr/expectations/duck_type_argument_equality_expectation_example.rb +68 -0
  20. data/examples/rr/expectations/is_a_argument_equality_expectation_example.rb +51 -0
  21. data/examples/rr/expectations/numeric_argument_equality_expectation_example.rb +47 -0
  22. data/examples/rr/expectations/range_argument_equality_expectation_example.rb +60 -0
  23. data/examples/rr/expectations/regexp_argument_equality_expectation_example.rb +68 -0
  24. data/examples/rr/expectations/times_called_expectation_example.rb +176 -0
  25. data/examples/rr/extensions/double_methods_example.rb +130 -0
  26. data/examples/rr/mock_creator_example.rb +65 -0
  27. data/examples/rr/probe_creator_example.rb +83 -0
  28. data/examples/rr/rspec/rspec_adapter_example.rb +64 -0
  29. data/examples/rr/rspec/rspec_usage_example.rb +38 -0
  30. data/examples/rr/scenario_example.rb +399 -0
  31. data/examples/rr/space_create_example.rb +185 -0
  32. data/examples/rr/space_example.rb +30 -0
  33. data/examples/rr/space_helper.rb +7 -0
  34. data/examples/rr/space_register_example.rb +33 -0
  35. data/examples/rr/space_reset_example.rb +73 -0
  36. data/examples/rr/space_verify_example.rb +146 -0
  37. data/examples/rr/stub_creator_example.rb +74 -0
  38. data/examples/rr/test_unit/test_helper.rb +9 -0
  39. data/examples/rr/test_unit/test_unit_integration_test.rb +39 -0
  40. data/examples/rspec_example_suite.rb +25 -0
  41. data/examples/test_unit_example_suite.rb +21 -0
  42. data/lib/rr.rb +27 -0
  43. data/lib/rr/adapters/rspec.rb +19 -0
  44. data/lib/rr/adapters/test_unit.rb +27 -0
  45. data/lib/rr/do_not_allow_creator.rb +39 -0
  46. data/lib/rr/double.rb +91 -0
  47. data/lib/rr/expectations/any_argument_expectation.rb +17 -0
  48. data/lib/rr/expectations/argument_equality_expectation.rb +35 -0
  49. data/lib/rr/expectations/times_called_expectation.rb +39 -0
  50. data/lib/rr/expectations/wildcard_matchers/anything.rb +15 -0
  51. data/lib/rr/expectations/wildcard_matchers/boolean.rb +20 -0
  52. data/lib/rr/expectations/wildcard_matchers/duck_type.rb +26 -0
  53. data/lib/rr/expectations/wildcard_matchers/is_a.rb +22 -0
  54. data/lib/rr/expectations/wildcard_matchers/numeric.rb +11 -0
  55. data/lib/rr/expectations/wildcard_matchers/range.rb +7 -0
  56. data/lib/rr/expectations/wildcard_matchers/regexp.rb +7 -0
  57. data/lib/rr/extensions/double_methods.rb +81 -0
  58. data/lib/rr/mock_creator.rb +32 -0
  59. data/lib/rr/probe_creator.rb +31 -0
  60. data/lib/rr/scenario.rb +184 -0
  61. data/lib/rr/scenario_not_found_error.rb +4 -0
  62. data/lib/rr/scenario_order_error.rb +4 -0
  63. data/lib/rr/space.rb +111 -0
  64. data/lib/rr/stub_creator.rb +36 -0
  65. metadata +113 -0
@@ -0,0 +1,65 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../example_helper"
3
+
4
+ module RR
5
+ describe MockCreator, :shared => true do
6
+ before(:each) do
7
+ @space = Space.new
8
+ @subject = Object.new
9
+ end
10
+
11
+ it "initializes creator with passed in object" do
12
+ class << @creator
13
+ attr_reader :subject
14
+ end
15
+ @creator.subject.should === @subject
16
+ end
17
+ end
18
+
19
+ describe MockCreator, ".new without block" do
20
+ it_should_behave_like "RR::MockCreator"
21
+
22
+ before do
23
+ @creator = MockCreator.new(@space, @subject)
24
+ end
25
+ end
26
+
27
+ describe MockCreator, ".new with block" do
28
+ it_should_behave_like "RR::MockCreator"
29
+
30
+ before do
31
+ @creator = MockCreator.new(@space, @subject) do |c|
32
+ c.foobar(1, 2) {:one_two}
33
+ c.foobar(1) {:one}
34
+ c.foobar.with_any_args {:default}
35
+ c.baz() {:baz_result}
36
+ end
37
+ end
38
+
39
+ it "creates doubles" do
40
+ @subject.foobar(1, 2).should == :one_two
41
+ @subject.foobar(1).should == :one
42
+ @subject.foobar(:something).should == :default
43
+ @subject.baz.should == :baz_result
44
+ end
45
+ end
46
+
47
+
48
+ describe MockCreator, "#method_missing" do
49
+ it_should_behave_like "RR::MockCreator"
50
+
51
+ before do
52
+ @subject = Object.new
53
+ @creator = MockCreator.new(@space, @subject)
54
+ end
55
+
56
+ it "sets expectations on the subject" do
57
+ @creator.foobar(1, 2) {:baz}.twice
58
+
59
+ @subject.foobar(1, 2).should == :baz
60
+ @subject.foobar(1, 2).should == :baz
61
+ proc {@subject.foobar(1, 2)}.should raise_error(Expectations::TimesCalledExpectationError)
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,83 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../example_helper"
3
+
4
+ module RR
5
+ describe ProbeCreator, :shared => true do
6
+ before(:each) do
7
+ @space = Space.new
8
+ @subject = Object.new
9
+ end
10
+
11
+ it "initializes creator with passed in object" do
12
+ class << @creator
13
+ attr_reader :subject
14
+ end
15
+ @creator.subject.should === @subject
16
+ end
17
+ end
18
+
19
+ describe ProbeCreator, ".new without block" do
20
+ it_should_behave_like "RR::ProbeCreator"
21
+
22
+ before do
23
+ @creator = ProbeCreator.new(@space, @subject)
24
+ end
25
+ end
26
+
27
+ describe ProbeCreator, ".new with block" do
28
+ it_should_behave_like "RR::ProbeCreator"
29
+
30
+ before do
31
+ def @subject.foobar(*args)
32
+ :original_foobar
33
+ end
34
+ @creator = ProbeCreator.new(@space, @subject) do |c|
35
+ c.foobar(1, 2)
36
+ c.foobar(1)
37
+ c.foobar.with_any_args
38
+ end
39
+ end
40
+
41
+ it "creates doubles" do
42
+ @subject.foobar(1, 2).should == :original_foobar
43
+ @subject.foobar(1).should == :original_foobar
44
+ @subject.foobar(:something).should == :original_foobar
45
+ proc {@subject.foobar(:nasty)}.should raise_error
46
+ end
47
+ end
48
+
49
+ describe ProbeCreator, ".new where method takes a block" do
50
+ it_should_behave_like "RR::ProbeCreator"
51
+
52
+ before do
53
+ def @subject.foobar(*args, &block)
54
+ yield(*args)
55
+ end
56
+ @creator = ProbeCreator.new(@space, @subject)
57
+ end
58
+
59
+ it "calls the block" do
60
+ @creator.foobar(1, 2)
61
+ @subject.foobar(1, 2) {|arg1, arg2| [arg2, arg1]}.should == [2, 1]
62
+ end
63
+ end
64
+
65
+
66
+ describe ProbeCreator, "#method_missing" do
67
+ it_should_behave_like "RR::ProbeCreator"
68
+
69
+ before do
70
+ @subject = Object.new
71
+ @creator = ProbeCreator.new(@space, @subject)
72
+ end
73
+
74
+ it "sets expectations on the subject while calling the original method" do
75
+ def @subject.foobar(*args); :baz; end
76
+ @creator.foobar(1, 2).twice
77
+ @subject.foobar(1, 2).should == :baz
78
+ @subject.foobar(1, 2).should == :baz
79
+ proc {@subject.foobar(1, 2)}.should raise_error(Expectations::TimesCalledExpectationError)
80
+ end
81
+ end
82
+
83
+ end
@@ -0,0 +1,64 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../../example_helper"
3
+
4
+ module RR
5
+ module Adapters
6
+ describe Rspec, "#setup_mocks_for_rspec" do
7
+ before do
8
+ @fixture = Object.new
9
+ @fixture.extend Rspec
10
+
11
+ @subject = Object.new
12
+ @method_name = :foobar
13
+ end
14
+
15
+ it "resets the doubles" do
16
+ RR::Space.instance.create_double(@subject, @method_name)
17
+ RR::Space.instance.doubles.should_not be_empty
18
+
19
+ @fixture.setup_mocks_for_rspec
20
+ RR::Space.instance.doubles.should be_empty
21
+ end
22
+ end
23
+
24
+ describe Rspec, "#verify_mocks_for_rspec" do
25
+ before do
26
+ @fixture = Object.new
27
+ @fixture.extend Rspec
28
+
29
+ @subject = Object.new
30
+ @method_name = :foobar
31
+ end
32
+
33
+ it "verifies the doubles" do
34
+ double = RR::Space.instance.create_double(@subject, @method_name)
35
+ scenario = RR::Space.instance.create_scenario(double)
36
+
37
+ scenario.once
38
+
39
+ proc do
40
+ @fixture.verify_mocks_for_rspec
41
+ end.should raise_error(::RR::Expectations::TimesCalledExpectationError)
42
+ RR::Space.instance.doubles.should be_empty
43
+ end
44
+ end
45
+
46
+ describe Rspec, "#teardown_mocks_for_rspec" do
47
+ before do
48
+ @fixture = Object.new
49
+ @fixture.extend Rspec
50
+
51
+ @subject = Object.new
52
+ @method_name = :foobar
53
+ end
54
+
55
+ it "resets the doubles" do
56
+ RR::Space.instance.create_double(@subject, @method_name)
57
+ RR::Space.instance.doubles.should_not be_empty
58
+
59
+ @fixture.teardown_mocks_for_rspec
60
+ RR::Space.instance.doubles.should be_empty
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,38 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../../example_helper"
3
+
4
+ describe RR, "#mock" do
5
+ before do
6
+ @subject = Object.new
7
+ end
8
+
9
+ it "creates a mock Double Scenario" do
10
+ mock(@subject).foobar(1, 2) {:baz}
11
+ @subject.foobar(1, 2).should == :baz
12
+ end
13
+ end
14
+
15
+ describe RR, "#stub" do
16
+ before do
17
+ @subject = Object.new
18
+ end
19
+
20
+ it "creates a stub Double Scenario" do
21
+ stub(@subject).foobar {:baz}
22
+ @subject.foobar("any", "thing").should == :baz
23
+ end
24
+ end
25
+
26
+ describe RR, "#probe" do
27
+ before do
28
+ @subject = Object.new
29
+ def @subject.foobar
30
+ :baz
31
+ end
32
+ end
33
+
34
+ it "creates a probe Double Scenario" do
35
+ probe(@subject).foobar
36
+ @subject.foobar.should == :baz
37
+ end
38
+ end
@@ -0,0 +1,399 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/../example_helper"
3
+
4
+ module RR
5
+ describe Scenario, :shared => true do
6
+ before do
7
+ @space = Space.new
8
+ @object = Object.new
9
+ @method_name = :foobar
10
+ @double = @space.create_double(@object, @method_name)
11
+ @scenario = @space.create_scenario(@double)
12
+ end
13
+ end
14
+
15
+ describe Scenario, "#with" do
16
+ it_should_behave_like "RR::Scenario"
17
+
18
+ it "sets an ArgumentEqualityExpectation" do
19
+ @scenario.with(1).should === @scenario
20
+ @scenario.should be_exact_match(1)
21
+ @scenario.should_not be_exact_match(2)
22
+ end
23
+
24
+ it "sets return value when block passed in" do
25
+ @scenario.with(1) {:return_value}
26
+ @object.foobar(1).should == :return_value
27
+ end
28
+ end
29
+
30
+ describe Scenario, "#with_any_args" do
31
+ it_should_behave_like "RR::Scenario"
32
+
33
+ before do
34
+ @scenario.with_any_args {:return_value}
35
+ end
36
+
37
+ it "returns self" do
38
+ @scenario.with_no_args.should === @scenario
39
+ end
40
+
41
+ it "sets an AnyArgumentExpectation" do
42
+ @scenario.should_not be_exact_match(1)
43
+ @scenario.should be_wildcard_match(1)
44
+ end
45
+
46
+ it "sets return value when block passed in" do
47
+ @object.foobar(:anything).should == :return_value
48
+ end
49
+ end
50
+
51
+ describe Scenario, "#with_no_args" do
52
+ it_should_behave_like "RR::Scenario"
53
+
54
+ before do
55
+ @scenario.with_no_args {:return_value}
56
+ end
57
+
58
+ it "returns self" do
59
+ @scenario.with_no_args.should === @scenario
60
+ end
61
+
62
+ it "sets an ArgumentEqualityExpectation with no arguments" do
63
+ @scenario.argument_expectation.should == Expectations::ArgumentEqualityExpectation.new()
64
+ end
65
+
66
+ it "sets return value when block passed in" do
67
+ @object.foobar().should == :return_value
68
+ end
69
+ end
70
+
71
+ describe Scenario, "#never" do
72
+ it_should_behave_like "RR::Scenario"
73
+
74
+ it "returns self" do
75
+ @scenario.never.should === @scenario
76
+ end
77
+
78
+ it "sets up a Times Called Expectation with 0" do
79
+ @scenario.never
80
+ proc {@scenario.call}.should raise_error(Expectations::TimesCalledExpectationError)
81
+ end
82
+
83
+ it "sets return value when block passed in" do
84
+ @scenario.with_any_args.never
85
+ proc {@scenario.call}.should raise_error(Expectations::TimesCalledExpectationError)
86
+ end
87
+ end
88
+
89
+ describe Scenario, "#once" do
90
+ it_should_behave_like "RR::Scenario"
91
+
92
+ it "sets up a Times Called Expectation with 1" do
93
+ @scenario.once.should === @scenario
94
+ @scenario.call
95
+ proc {@scenario.call}.should raise_error(Expectations::TimesCalledExpectationError)
96
+ end
97
+
98
+ it "sets return value when block passed in" do
99
+ @scenario.with_any_args.once {:return_value}
100
+ @object.foobar.should == :return_value
101
+ end
102
+ end
103
+
104
+ describe Scenario, "#twice" do
105
+ it_should_behave_like "RR::Scenario"
106
+
107
+ it "sets up a Times Called Expectation with 2" do
108
+ @scenario.twice.should === @scenario
109
+ @scenario.call
110
+ @scenario.call
111
+ proc {@scenario.call}.should raise_error(Expectations::TimesCalledExpectationError)
112
+ end
113
+
114
+ it "sets return value when block passed in" do
115
+ @scenario.with_any_args.twice {:return_value}
116
+ @object.foobar.should == :return_value
117
+ end
118
+ end
119
+
120
+ describe Scenario, "#times" do
121
+ it_should_behave_like "RR::Scenario"
122
+
123
+ it "sets up a Times Called Expectation with passed in times" do
124
+ @scenario.times(3).should === @scenario
125
+ @scenario.call
126
+ @scenario.call
127
+ @scenario.call
128
+ proc {@scenario.call}.should raise_error(Expectations::TimesCalledExpectationError)
129
+ end
130
+
131
+ it "sets return value when block passed in" do
132
+ @scenario.with_any_args.times(3) {:return_value}
133
+ @object.foobar.should == :return_value
134
+ end
135
+ end
136
+
137
+ describe Scenario, "#ordered" do
138
+ it_should_behave_like "RR::Scenario"
139
+
140
+ it "adds itself to the ordered scenarios list" do
141
+ @scenario.ordered
142
+ @space.ordered_scenarios.should include(@scenario)
143
+ end
144
+
145
+ it "does not double add itself" do
146
+ @scenario.ordered
147
+ @scenario.ordered
148
+ @space.ordered_scenarios.should == [@scenario ]
149
+ end
150
+
151
+ it "sets ordered? to true" do
152
+ @scenario.ordered
153
+ @scenario.should be_ordered
154
+ end
155
+
156
+ it "sets return value when block passed in" do
157
+ @scenario.with_any_args.ordered {:return_value}
158
+ @object.foobar.should == :return_value
159
+ end
160
+ end
161
+
162
+ describe Scenario, "#ordered?" do
163
+ it_should_behave_like "RR::Scenario"
164
+
165
+ it "defaults to false" do
166
+ @scenario.should_not be_ordered
167
+ end
168
+ end
169
+
170
+ describe Scenario, "#returns" do
171
+ it_should_behave_like "RR::Scenario"
172
+
173
+ it "sets the value of the method" do
174
+ @scenario.returns {:baz}.should === @scenario
175
+ @scenario.call.should == :baz
176
+ end
177
+ end
178
+
179
+ describe Scenario, "#implemented_by" do
180
+ it_should_behave_like "RR::Scenario"
181
+
182
+ it "returns the scenario object" do
183
+ @scenario.implemented_by(proc{:baz}).should === @scenario
184
+ end
185
+
186
+ it "sets the implementation to the passed in proc" do
187
+ @scenario.implemented_by(proc{:baz})
188
+ @scenario.call.should == :baz
189
+ end
190
+
191
+ it "sets the implementation to the passed in method" do
192
+ def @object.foobar(a, b)
193
+ [b, a]
194
+ end
195
+ @scenario.implemented_by(@object.method(:foobar))
196
+ @scenario.call(1, 2).should == [2, 1]
197
+ end
198
+ end
199
+
200
+ describe Scenario, "#call implemented by a proc" do
201
+ it_should_behave_like "RR::Scenario"
202
+
203
+ it "calls the return proc when scheduled to call a proc" do
204
+ @scenario.returns {|arg| "returning #{arg}"}
205
+ @scenario.call(:foobar).should == "returning foobar"
206
+ end
207
+
208
+ it "returns nil when to returns is not set" do
209
+ @scenario.call.should be_nil
210
+ end
211
+
212
+ it "works when times_called is not set" do
213
+ @scenario.returns {:value}
214
+ @scenario.call
215
+ end
216
+
217
+ it "verifes the times_called does not exceed the TimesCalledExpectation" do
218
+ @scenario.times(2).returns {:value}
219
+
220
+ @scenario.call(:foobar)
221
+ @scenario.call(:foobar)
222
+ proc {@scenario.call(:foobar)}.should raise_error(Expectations::TimesCalledExpectationError)
223
+ end
224
+
225
+ it "raises ScenarioOrderError when ordered and called out of order" do
226
+ scenario1 = @scenario
227
+ scenario2 = @space.create_scenario(@double)
228
+
229
+ scenario1.with(1).returns {:return_1}.ordered
230
+ scenario2.with(2).returns {:return_2}.ordered
231
+
232
+ proc do
233
+ @object.foobar(2)
234
+ end.should raise_error(::RR::ScenarioOrderError)
235
+ end
236
+
237
+ it "dispatches to Space#verify_ordered_scenario when ordered" do
238
+ verify_ordered_scenario_called = false
239
+ passed_in_scenario = nil
240
+ @space.method(:verify_ordered_scenario).arity.should == 1
241
+ (class << @space; self; end).class_eval do
242
+ define_method :verify_ordered_scenario do |scenario|
243
+ passed_in_scenario = scenario
244
+ verify_ordered_scenario_called = true
245
+ end
246
+ end
247
+
248
+ @scenario.returns {:value}.ordered
249
+ @scenario.call(:foobar)
250
+ verify_ordered_scenario_called.should be_true
251
+ passed_in_scenario.should === @scenario
252
+ end
253
+
254
+ it "does not dispatche to Space#verify_ordered_scenario when not ordered" do
255
+ verify_ordered_scenario_called = false
256
+ @space.method(:verify_ordered_scenario).arity.should == 1
257
+ (class << @space; self; end).class_eval do
258
+ define_method :verify_ordered_scenario do |scenario|
259
+ verify_ordered_scenario_called = true
260
+ end
261
+ end
262
+
263
+ @scenario.returns {:value}
264
+ @scenario.call(:foobar)
265
+ verify_ordered_scenario_called.should be_false
266
+ end
267
+
268
+ it "does not add block argument if no block passed in" do
269
+ @scenario.with(1, 2).returns {|*args| args}
270
+
271
+ args = @object.foobar(1, 2)
272
+ args.should == [1, 2]
273
+ end
274
+
275
+ it "makes the block the last argument" do
276
+ @scenario.with(1, 2).returns {|a, b, blk| blk}
277
+
278
+ block = @object.foobar(1, 2) {|a, b| [b, a]}
279
+ block.call(3, 4).should == [4, 3]
280
+ end
281
+ end
282
+
283
+ describe Scenario, "#call implemented by a method" do
284
+ it_should_behave_like "RR::Scenario"
285
+
286
+ it "sends block to the method" do
287
+ def @object.foobar(a, b)
288
+ yield(a, b)
289
+ end
290
+
291
+ @scenario.with(1, 2).implemented_by(@object.method(:foobar))
292
+
293
+ @object.foobar(1, 2) {|a, b| [b, a]}.should == [2, 1]
294
+ end
295
+ end
296
+
297
+ describe Scenario, "#exact_match?" do
298
+ it_should_behave_like "RR::Scenario"
299
+
300
+ it "returns false when no expectation set" do
301
+ @scenario.should_not be_exact_match()
302
+ @scenario.should_not be_exact_match(nil)
303
+ @scenario.should_not be_exact_match(Object.new)
304
+ @scenario.should_not be_exact_match(1, 2, 3)
305
+ end
306
+
307
+ it "returns false when arguments are not an exact match" do
308
+ @scenario.with(1, 2, 3)
309
+ @scenario.should_not be_exact_match(1, 2)
310
+ @scenario.should_not be_exact_match(1)
311
+ @scenario.should_not be_exact_match()
312
+ @scenario.should_not be_exact_match("does not match")
313
+ end
314
+
315
+ it "returns true when arguments are an exact match" do
316
+ @scenario.with(1, 2, 3)
317
+ @scenario.should be_exact_match(1, 2, 3)
318
+ end
319
+ end
320
+
321
+ describe Scenario, "#wildcard_match?" do
322
+ it_should_behave_like "RR::Scenario"
323
+
324
+ it "returns false when no expectation set" do
325
+ @scenario.should_not be_wildcard_match()
326
+ @scenario.should_not be_wildcard_match(nil)
327
+ @scenario.should_not be_wildcard_match(Object.new)
328
+ @scenario.should_not be_wildcard_match(1, 2, 3)
329
+ end
330
+
331
+ it "returns true when arguments are an exact match" do
332
+ @scenario.with(1, 2, 3)
333
+ @scenario.should be_wildcard_match(1, 2, 3)
334
+ @scenario.should_not be_wildcard_match(1, 2)
335
+ @scenario.should_not be_wildcard_match(1)
336
+ @scenario.should_not be_wildcard_match()
337
+ @scenario.should_not be_wildcard_match("does not match")
338
+ end
339
+
340
+ it "returns true when with_any_args" do
341
+ @scenario.with_any_args
342
+
343
+ @scenario.should be_wildcard_match(1, 2, 3)
344
+ @scenario.should be_wildcard_match(1, 2)
345
+ @scenario.should be_wildcard_match(1)
346
+ @scenario.should be_wildcard_match()
347
+ @scenario.should be_wildcard_match("does not match")
348
+ end
349
+ end
350
+
351
+ describe Scenario, "#times_called_verified?" do
352
+ it_should_behave_like "RR::Scenario"
353
+
354
+ it "returns false when times called does not match expectation" do
355
+ @scenario.with(1, 2, 3).twice
356
+ @object.foobar(1, 2, 3)
357
+ @scenario.should_not be_times_called_verified
358
+ end
359
+
360
+ it "returns true when times called matches expectation" do
361
+ @scenario.with(1, 2, 3).twice
362
+ @object.foobar(1, 2, 3)
363
+ @object.foobar(1, 2, 3)
364
+ @scenario.should be_times_called_verified
365
+ end
366
+
367
+ it "returns false when there is no Times Called expectation" do
368
+ @scenario.with(1, 2, 3)
369
+ @scenario.times_called_expectation.should be_nil
370
+
371
+ @scenario.should_not be_times_called_verified
372
+ @object.foobar(1, 2, 3)
373
+ @scenario.should_not be_times_called_verified
374
+ end
375
+ end
376
+
377
+ describe Scenario, "#verify" do
378
+ it_should_behave_like "RR::Scenario"
379
+
380
+ it "verifies that times called expectation was met" do
381
+ @scenario.twice.returns {:return_value}
382
+
383
+ proc {@scenario.verify}.should raise_error(Expectations::TimesCalledExpectationError)
384
+ @scenario.call
385
+ proc {@scenario.verify}.should raise_error(Expectations::TimesCalledExpectationError)
386
+ @scenario.call
387
+
388
+ proc {@scenario.verify}.should_not raise_error
389
+ end
390
+
391
+ it "does not raise an error when there is no times called expectation" do
392
+ proc {@scenario.verify}.should_not raise_error
393
+ @scenario.call
394
+ proc {@scenario.verify}.should_not raise_error
395
+ @scenario.call
396
+ proc {@scenario.verify}.should_not raise_error
397
+ end
398
+ end
399
+ end