rr 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGES +5 -0
  2. data/README +20 -9
  3. data/Rakefile +1 -1
  4. data/examples/example_suite.rb +1 -1
  5. data/examples/high_level_example.rb +4 -4
  6. data/examples/rr/double/double_dispatching_example.rb +41 -41
  7. data/examples/rr/double/double_verify_example.rb +1 -1
  8. data/examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +2 -2
  9. data/examples/rr/extensions/instance_methods_creator_example.rb +48 -38
  10. data/examples/rr/extensions/instance_methods_space_example.rb +8 -8
  11. data/examples/rr/rspec/rspec_adapter_example.rb +9 -9
  12. data/examples/rr/rspec/rspec_usage_example.rb +16 -2
  13. data/examples/rr/scenario_creator_example.rb +400 -0
  14. data/examples/rr/scenario_example.rb +19 -4
  15. data/examples/rr/scenario_method_proxy_example.rb +71 -0
  16. data/examples/rr/space/space_create_example.rb +93 -106
  17. data/examples/rr/space/space_example.rb +2 -2
  18. data/examples/rr/space/space_register_example.rb +3 -3
  19. data/examples/rr/space/space_reset_example.rb +11 -11
  20. data/examples/rr/space/space_verify_example.rb +12 -12
  21. data/examples/rr/test_unit/test_unit_integration_test.rb +11 -2
  22. data/lib/rr.rb +10 -12
  23. data/lib/rr/errors/scenario_definition_error.rb +6 -0
  24. data/lib/rr/extensions/instance_methods.rb +84 -84
  25. data/lib/rr/scenario.rb +18 -3
  26. data/lib/rr/scenario_creator.rb +233 -0
  27. data/lib/rr/scenario_method_proxy.rb +19 -0
  28. data/lib/rr/space.rb +12 -32
  29. metadata +7 -13
  30. data/examples/rr/do_not_allow_creator_example.rb +0 -111
  31. data/examples/rr/mock_creator_example.rb +0 -87
  32. data/examples/rr/mock_probe_creator_example.rb +0 -120
  33. data/examples/rr/stub_creator_example.rb +0 -96
  34. data/examples/rr/stub_probe_creator_example.rb +0 -127
  35. data/lib/rr/creator.rb +0 -16
  36. data/lib/rr/do_not_allow_creator.rb +0 -33
  37. data/lib/rr/mock_creator.rb +0 -26
  38. data/lib/rr/mock_probe_creator.rb +0 -36
  39. data/lib/rr/stub_creator.rb +0 -30
  40. data/lib/rr/stub_probe_creator.rb +0 -42
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ * 0.3.0
2
+ - ScenarioCreator strategy method chaining
3
+ - Removed mock_probe
4
+ - Removed stub_probe
5
+
1
6
  * 0.2.5
2
7
  - mock takes method_name argument
3
8
  - stub takes method_name argument
data/README CHANGED
@@ -7,44 +7,54 @@ http://xunitpatterns.com/Test%20Double.html
7
7
  Currently RR implements mocks, stubs, and probes. It is a goal of
8
8
  RR to support a wide range of double techniques and patterns.
9
9
 
10
- == Mocking
10
+ == Mocks
11
11
  http://xunitpatterns.com/Mock%20Object.html
12
12
  view = controller.template
13
13
  mock(view).render(:partial => "user_info") {"Information"}
14
14
 
15
- == Stubbing
15
+ # or
16
+ mock(view) do
17
+ render(:partial => "user_info") {"Information"}
18
+ end
19
+
20
+ == Stubs
16
21
  http://xunitpatterns.com/Test%20Stub.html
17
22
  jane = User.new
18
23
  stub(User).find('42') {jane}
19
- mock(jane).valid? {true}
20
24
 
21
- == Mock Probing
25
+ == Mock Probes
22
26
  Add verifications that a method was called while actually calling it.
23
27
  The following example verifies render partial will be called and
24
28
  renders the partial.
25
29
 
26
30
  view = controller.template
27
- probe(view).render(:partial => "user_info")
28
- # or mock_probe.render(:partial => "user_info")
31
+ mock.probe(view).render(:partial => "right_navigation")
32
+ mock.probe(view).render(:partial => "user_info") do |html|
33
+ html.should include("John Doe")
34
+ "Different html"
35
+ end
29
36
 
30
- Probes also support after_call callbacks. This is useful for Stubbing out
37
+ Probes support after_call callbacks. This is useful for Stubbing out
31
38
  a class method and getting its return value. You can also change the return value.
32
39
  This technique is also useful for verifying that you are mocking exists and
33
40
  functions proberly, thereby testing you interface.
34
41
  For example, using ActiveRecord:
35
42
 
36
43
  probe(User).find('5') do |user|
44
+ mock.probe(user).projects do |projects|
45
+ projects[0..3]
46
+ end
37
47
  mock(user).valid? {false}
38
48
  user
39
49
  end
40
50
 
41
- == Mock Stubbing
51
+ == Stub Probes
42
52
  Intercept the return value of a method call.
43
53
  The following example verifies render partial will be called and
44
54
  renders the partial.
45
55
 
46
56
  view = controller.template
47
- stub_probe(view).render(:partial => "user_info") do |html|
57
+ stub.probe(view).render(:partial => "user_info") do |html|
48
58
  html.should include("Joe Smith")
49
59
  html
50
60
  end
@@ -65,6 +75,7 @@ Here is RR compared to other mock frameworks:
65
75
  flexmock(User).should_receive(:find).with('42').and_return(jane) # Flexmock
66
76
  User.should_receive(:find).with('42').and_return(jane) # Rspec
67
77
  User.expects(:find).with('42').returns {jane} # Mocha
78
+ User.should_receive(:find).with('42') {jane} # Rspec using return value blocks
68
79
  mock(User).find('42') {jane} # RR
69
80
 
70
81
  == Special Thanks To
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ def run_suite
21
21
  end
22
22
 
23
23
  PKG_NAME = "rr"
24
- PKG_VERSION = "0.2.5"
24
+ PKG_VERSION = "0.3.0"
25
25
  PKG_FILES = FileList[
26
26
  '[A-Z]*',
27
27
  '*.rb',
@@ -42,4 +42,4 @@ end
42
42
 
43
43
  if $0 == __FILE__
44
44
  ExampleSuite.new.run
45
- end
45
+ end
@@ -67,7 +67,7 @@ describe "RR probe:" do
67
67
 
68
68
  it "probes via inline call" do
69
69
  expected_to_s_value = @obj.to_s
70
- probe(@obj).to_s
70
+ mock.probe(@obj).to_s
71
71
  @obj.to_s.should == expected_to_s_value
72
72
  proc {@obj.to_s}.should raise_error
73
73
  end
@@ -76,8 +76,8 @@ describe "RR probe:" do
76
76
  def @obj.to_s(arg)
77
77
  "Original to_s with arg #{arg}"
78
78
  end
79
- probe(@obj).to_s(:foo).ordered
80
- probe(@obj).to_s(:bar).twice.ordered
79
+ mock.probe(@obj).to_s(:foo).ordered
80
+ mock.probe(@obj).to_s(:bar).twice.ordered
81
81
 
82
82
  @obj.to_s(:foo).should == "Original to_s with arg foo"
83
83
  @obj.to_s(:bar).should == "Original to_s with arg bar"
@@ -94,7 +94,7 @@ describe "RR probe:" do
94
94
  :original_value_2
95
95
  end
96
96
 
97
- probe @obj do |c|
97
+ mock.probe @obj do |c|
98
98
  c.foobar_1(1)
99
99
  c.foobar_2
100
100
  end
@@ -7,7 +7,7 @@ describe Double, "method dispatching", :shared => true do
7
7
  @object = Object.new
8
8
  @method_name = :foobar
9
9
  @object.methods.should_not include(@method_name.to_s)
10
- @double = @space.create_double(@object, @method_name)
10
+ @double = @space.double(@object, @method_name)
11
11
  end
12
12
  end
13
13
 
@@ -17,11 +17,11 @@ describe Double, " method dispatching where method name has a ! in it" do
17
17
  @object = Object.new
18
18
  @method_name = :foobar!
19
19
  @object.methods.should_not include(@method_name.to_s)
20
- @double = @space.create_double(@object, @method_name)
20
+ @double = @space.double(@object, @method_name)
21
21
  end
22
22
 
23
23
  it "executes the block" do
24
- scenario = @space.create_scenario(@double)
24
+ scenario = @space.scenario(@double)
25
25
  scenario.with(1, 2) {:return_value}
26
26
  @object.foobar!(1, 2).should == :return_value
27
27
  end
@@ -33,11 +33,11 @@ describe Double, " method dispatching where method name has a ? in it" do
33
33
  @object = Object.new
34
34
  @method_name = :foobar?
35
35
  @object.methods.should_not include(@method_name.to_s)
36
- @double = @space.create_double(@object, @method_name)
36
+ @double = @space.double(@object, @method_name)
37
37
  end
38
38
 
39
39
  it "executes the block" do
40
- scenario = @space.create_scenario(@double)
40
+ scenario = @space.scenario(@double)
41
41
  scenario.with(1, 2) {:return_value}
42
42
  @object.foobar?(1, 2).should == :return_value
43
43
  end
@@ -53,7 +53,7 @@ describe Double, " method dispatching where the scenario takes a block" do
53
53
  yield(a,b)
54
54
  end
55
55
  end
56
- scenario = @space.create_scenario(@double)
56
+ scenario = @space.scenario(@double)
57
57
  scenario.with(1, 2).implemented_by(method_fixture.method(:method_with_block))
58
58
  @object.foobar(1, 2) {|a, b| [b, a]}.should == [2, 1]
59
59
  end
@@ -63,11 +63,11 @@ describe Double, " method dispatching where there are no scenarios with duplicat
63
63
  it_should_behave_like "RR::Double method dispatching"
64
64
 
65
65
  it "dispatches to Scenario that have an exact match" do
66
- scenario1_with_exact_match = @space.create_scenario(@double)
66
+ scenario1_with_exact_match = @space.scenario(@double)
67
67
  scenario1_with_exact_match.with(:exact_match_1).returns {:return_1}
68
- scenario_with_no_match = @space.create_scenario(@double)
68
+ scenario_with_no_match = @space.scenario(@double)
69
69
  scenario_with_no_match.with("nothing that matches").returns {:no_match}
70
- scenario2_with_exact_match = @space.create_scenario(@double)
70
+ scenario2_with_exact_match = @space.scenario(@double)
71
71
  scenario2_with_exact_match.with(:exact_match_2).returns {:return_2}
72
72
 
73
73
  @object.foobar(:exact_match_1).should == :return_1
@@ -75,9 +75,9 @@ describe Double, " method dispatching where there are no scenarios with duplicat
75
75
  end
76
76
 
77
77
  it "dispatches to Scenario that have a wildcard match" do
78
- scenario_with_wildcard_match = @space.create_scenario(@double)
78
+ scenario_with_wildcard_match = @space.scenario(@double)
79
79
  scenario_with_wildcard_match.with_any_args.returns {:wild_card_value}
80
- scenario_with_no_match = @space.create_scenario(@double)
80
+ scenario_with_no_match = @space.scenario(@double)
81
81
  scenario_with_no_match.with("nothing that matches").returns {:no_match}
82
82
 
83
83
  @object.foobar(:wildcard_match_1).should == :wild_card_value
@@ -89,10 +89,10 @@ describe Double, " method dispatching where there are scenarios" do
89
89
  it_should_behave_like "RR::Double method dispatching"
90
90
 
91
91
  it "raises ScenarioNotFoundError error when arguments do not match a scenario" do
92
- scenario_1 = @space.create_scenario(@double)
92
+ scenario_1 = @space.scenario(@double)
93
93
  scenario_1.with(1, 2)
94
94
 
95
- scenario_2 = @space.create_scenario(@double)
95
+ scenario_2 = @space.scenario(@double)
96
96
  scenario_2.with(3)
97
97
 
98
98
  proc {@object.foobar(:arg1, :arg2)}.should raise_error(
@@ -108,38 +108,38 @@ describe Double, " method dispatching where there are Scenarios with NonTerminal
108
108
  it_should_behave_like "RR::Double method dispatching"
109
109
 
110
110
  it "dispatches to Scenario with exact match" do
111
- scenario = create_scenario(1, 2) {:return_value}
111
+ scenario = scenario(1, 2) {:return_value}
112
112
  @object.foobar(1, 2).should == :return_value
113
113
  end
114
114
 
115
115
  it "matches to the last Scenario that was registered with an exact match" do
116
- scenario_1 = create_scenario(1, 2) {:value_1}
117
- scenario_2 = create_scenario(1, 2) {:value_2}
116
+ scenario_1 = scenario(1, 2) {:value_1}
117
+ scenario_2 = scenario(1, 2) {:value_2}
118
118
 
119
119
  @object.foobar(1, 2).should == :value_2
120
120
  end
121
121
 
122
122
  it "dispatches to Scenario with wildcard match" do
123
- scenario = create_scenario(anything) {:return_value}
123
+ scenario = scenario(anything) {:return_value}
124
124
  @object.foobar(:dont_care).should == :return_value
125
125
  end
126
126
 
127
127
  it "matches to the last Scenario that was registered with a wildcard match" do
128
- scenario_1 = create_scenario(anything) {:value_1}
129
- scenario_2 = create_scenario(anything) {:value_2}
128
+ scenario_1 = scenario(anything) {:value_1}
129
+ scenario_2 = scenario(anything) {:value_2}
130
130
 
131
131
  @object.foobar(:dont_care).should == :value_2
132
132
  end
133
133
 
134
134
  it "matches to Scenario with exact match Scenario even when a Scenario with wildcard match was registered later" do
135
- exact_scenario_registered_first = create_scenario(1, 2) {:exact_first}
136
- wildcard_scenario_registered_last = create_scenario(anything, anything) {:wildcard_last}
135
+ exact_scenario_registered_first = scenario(1, 2) {:exact_first}
136
+ wildcard_scenario_registered_last = scenario(anything, anything) {:wildcard_last}
137
137
 
138
138
  @object.foobar(1, 2).should == :exact_first
139
139
  end
140
140
 
141
- def create_scenario(*arguments, &return_value)
142
- scenario = @space.create_scenario(@double)
141
+ def scenario(*arguments, &return_value)
142
+ scenario = @space.scenario(@double)
143
143
  scenario.with(*arguments).any_number_of_times.returns(&return_value)
144
144
  scenario.should_not be_terminal
145
145
  scenario
@@ -150,30 +150,30 @@ describe Double, " method dispatching where there are Terminal Scenarios with du
150
150
  it_should_behave_like "RR::Double method dispatching"
151
151
 
152
152
  it "dispatches to Scenario that have an exact match" do
153
- scenario1_with_exact_match = create_scenario(:exact_match) {:return_1}
153
+ scenario1_with_exact_match = scenario(:exact_match) {:return_1}
154
154
 
155
155
  @object.foobar(:exact_match).should == :return_1
156
156
  end
157
157
 
158
158
  it "dispatches to the first Scenario that have an exact match" do
159
- scenario1_with_exact_match = create_scenario(:exact_match) {:return_1}
160
- scenario2_with_exact_match = create_scenario(:exact_match) {:return_2}
159
+ scenario1_with_exact_match = scenario(:exact_match) {:return_1}
160
+ scenario2_with_exact_match = scenario(:exact_match) {:return_2}
161
161
 
162
162
  @object.foobar(:exact_match).should == :return_1
163
163
  end
164
164
 
165
165
  it "dispatches the second Scenario with an exact match
166
166
  when the first scenario's Times Called expectation is satisfied" do
167
- scenario1_with_exact_match = create_scenario(:exact_match) {:return_1}
168
- scenario2_with_exact_match = create_scenario(:exact_match) {:return_2}
167
+ scenario1_with_exact_match = scenario(:exact_match) {:return_1}
168
+ scenario2_with_exact_match = scenario(:exact_match) {:return_2}
169
169
 
170
170
  @object.foobar(:exact_match)
171
171
  @object.foobar(:exact_match).should == :return_2
172
172
  end
173
173
 
174
174
  it "raises TimesCalledError when all of the scenarios Times Called expectation is satisfied" do
175
- scenario1_with_exact_match = create_scenario(:exact_match) {:return_1}
176
- scenario2_with_exact_match = create_scenario(:exact_match) {:return_2}
175
+ scenario1_with_exact_match = scenario(:exact_match) {:return_1}
176
+ scenario2_with_exact_match = scenario(:exact_match) {:return_2}
177
177
 
178
178
  @object.foobar(:exact_match)
179
179
  @object.foobar(:exact_match)
@@ -182,8 +182,8 @@ describe Double, " method dispatching where there are Terminal Scenarios with du
182
182
  end.should raise_error(Errors::TimesCalledError)
183
183
  end
184
184
 
185
- def create_scenario(*arguments, &return_value)
186
- scenario = @space.create_scenario(@double)
185
+ def scenario(*arguments, &return_value)
186
+ scenario = @space.scenario(@double)
187
187
  scenario.with(*arguments).once.returns(&return_value)
188
188
  scenario.should be_terminal
189
189
  scenario
@@ -194,30 +194,30 @@ describe Double, " method dispatching where there are scenarios with duplicate W
194
194
  it_should_behave_like "RR::Double method dispatching"
195
195
 
196
196
  it "dispatches to Scenario that have a wildcard match" do
197
- scenario_1 = create_scenario {:return_1}
197
+ scenario_1 = scenario {:return_1}
198
198
 
199
199
  @object.foobar(:anything).should == :return_1
200
200
  end
201
201
 
202
202
  it "dispatches to the first Scenario that has a wildcard match" do
203
- scenario_1 = create_scenario {:return_1}
204
- scenario_2 = create_scenario {:return_2}
203
+ scenario_1 = scenario {:return_1}
204
+ scenario_2 = scenario {:return_2}
205
205
 
206
206
  @object.foobar(:anything).should == :return_1
207
207
  end
208
208
 
209
209
  it "dispatches the second Scenario with a wildcard match
210
210
  when the first scenario's Times Called expectation is satisfied" do
211
- scenario_1 = create_scenario {:return_1}
212
- scenario_2 = create_scenario {:return_2}
211
+ scenario_1 = scenario {:return_1}
212
+ scenario_2 = scenario {:return_2}
213
213
 
214
214
  @object.foobar(:anything)
215
215
  @object.foobar(:anything).should == :return_2
216
216
  end
217
217
 
218
218
  it "raises TimesCalledError when all of the scenarios Times Called expectation is satisfied" do
219
- scenario_1 = create_scenario {:return_1}
220
- scenario_2 = create_scenario {:return_2}
219
+ scenario_1 = scenario {:return_1}
220
+ scenario_2 = scenario {:return_2}
221
221
 
222
222
  @object.foobar(:anything)
223
223
  @object.foobar(:anything)
@@ -226,8 +226,8 @@ describe Double, " method dispatching where there are scenarios with duplicate W
226
226
  end.should raise_error(Errors::TimesCalledError)
227
227
  end
228
228
 
229
- def create_scenario(&return_value)
230
- scenario = @space.create_scenario(@double)
229
+ def scenario(&return_value)
230
+ scenario = @space.scenario(@double)
231
231
  scenario.with_any_args.once.returns(&return_value)
232
232
  scenario.should be_terminal
233
233
  scenario
@@ -7,7 +7,7 @@ describe Double, "#verify" do
7
7
  @object = Object.new
8
8
  @method_name = :foobar
9
9
  @object.methods.should_not include(@method_name.to_s)
10
- @double = @space.create_double(@object, @method_name)
10
+ @double = @space.double(@object, @method_name)
11
11
  end
12
12
 
13
13
  it "verifies each scenario was met" do
@@ -5,8 +5,8 @@ module Expectations
5
5
  @space = Space.new
6
6
  @object = Object.new
7
7
  @method_name = :foobar
8
- @double = @space.create_double(@object, @method_name)
9
- @scenario = @space.create_scenario(@double)
8
+ @double = @space.double(@object, @method_name)
9
+ @scenario = @space.scenario(@double)
10
10
  @scenario.with_any_args
11
11
  end
12
12
 
@@ -14,6 +14,10 @@ module Extensions
14
14
  end
15
15
  end
16
16
 
17
+ it "returns a ScenarioCreator when passed no arguments" do
18
+ mock.should be_instance_of(ScenarioCreator)
19
+ end
20
+
17
21
  it "sets up the RR mock call chain" do
18
22
  should create_mock_call_chain(mock(@subject))
19
23
  end
@@ -68,6 +72,10 @@ module Extensions
68
72
  end
69
73
  end
70
74
 
75
+ it "returns a ScenarioCreator when passed no arguments" do
76
+ stub.should be_instance_of(ScenarioCreator)
77
+ end
78
+
71
79
  it "sets up the RR stub call chain" do
72
80
  should create_stub_call_chain(stub(@subject))
73
81
  end
@@ -106,7 +114,7 @@ module Extensions
106
114
  end
107
115
  end
108
116
 
109
- describe InstanceMethods, "#probe and #mock_probe" do
117
+ describe InstanceMethods, "#probe and #mock" do
110
118
  it_should_behave_like "RR::Extensions::InstanceMethods"
111
119
 
112
120
  before do
@@ -118,41 +126,45 @@ module Extensions
118
126
  end
119
127
  end
120
128
 
129
+ it "#probe returns a ScenarioCreator when passed no arguments" do
130
+ probe.should be_instance_of(ScenarioCreator)
131
+ end
132
+
121
133
  it "#probe sets up the RR probe call chain" do
122
- should create_mock_probe_call_chain(probe(@subject))
134
+ should create_mock_probe_call_chain(mock.probe(@subject))
123
135
  end
124
136
 
125
137
  it "#rr_probe sets up the RR probe call chain" do
126
- should create_mock_probe_call_chain(rr_probe(@subject))
138
+ should create_mock_probe_call_chain(rr_mock.probe(@subject))
127
139
  end
128
140
 
129
141
  it "#mock_probe sets up the RR probe call chain" do
130
- should create_mock_probe_call_chain(mock_probe(@subject))
142
+ should create_mock_probe_call_chain(mock.probe(@subject))
131
143
  end
132
144
 
133
145
  it "#rr_mock_probe sets up the RR probe call chain with rr_probe" do
134
- should create_mock_probe_call_chain(rr_mock_probe(@subject))
146
+ should create_mock_probe_call_chain(rr_mock.probe(@subject))
135
147
  end
136
148
 
137
149
  it "#probe creates a mock Scenario for method when passed a second argument" do
138
- should create_scenario_with_method_name(probe(@subject, :foobar))
150
+ should create_scenario_with_method_name(mock.probe(@subject, :foobar))
139
151
  end
140
152
 
141
153
  it "#rr_probe creates a mock Scenario for method when passed a second argument with rr_mock" do
142
- should create_scenario_with_method_name(rr_probe(@subject, :foobar))
154
+ should create_scenario_with_method_name(rr_probe.mock(@subject, :foobar))
143
155
  end
144
156
 
145
157
  it "#mock_probe creates a mock Scenario for method when passed a second argument" do
146
- should create_scenario_with_method_name(mock_probe(@subject, :foobar))
158
+ should create_scenario_with_method_name(mock.probe(@subject, :foobar))
147
159
  end
148
160
 
149
161
  it "#rr_mock_probe creates a mock Scenario for method when passed a second argument with rr_mock" do
150
- should create_scenario_with_method_name(rr_mock_probe(@subject, :foobar))
162
+ should create_scenario_with_method_name(rr_mock.probe(@subject, :foobar))
151
163
  end
152
164
 
153
165
  it "raises error if passed a method name and a block" do
154
166
  proc do
155
- mock_probe(@object, :foobar) {}
167
+ mock.probe(@object, :foobar) {}
156
168
  end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
157
169
  end
158
170
 
@@ -176,7 +188,7 @@ module Extensions
176
188
  end
177
189
  end
178
190
 
179
- describe InstanceMethods, "#stub_probe" do
191
+ describe InstanceMethods, "#stub and #probe" do
180
192
  it_should_behave_like "RR::Extensions::InstanceMethods"
181
193
 
182
194
  before do
@@ -188,25 +200,29 @@ module Extensions
188
200
  end
189
201
  end
190
202
 
203
+ it "returns a ScenarioCreator when passed no arguments" do
204
+ stub.probe.should be_instance_of(ScenarioCreator)
205
+ end
206
+
191
207
  it "sets up the RR probe call chain" do
192
- should create_stub_probe_call_chain(stub_probe(@subject))
208
+ should create_stub_probe_call_chain(stub.probe(@subject))
193
209
  end
194
210
 
195
211
  it "sets up the RR probe call chain" do
196
- should create_stub_probe_call_chain(rr_stub_probe(@subject))
212
+ should create_stub_probe_call_chain(rr_stub.probe(@subject))
197
213
  end
198
214
 
199
- it "#stub_probe creates a stub Scenario for method when passed a second argument" do
200
- should create_scenario_with_method_name(stub_probe(@subject, :foobar))
215
+ it "#stub.probe creates a stub Scenario for method when passed a second argument" do
216
+ should create_scenario_with_method_name(stub.probe(@subject, :foobar))
201
217
  end
202
218
 
203
- it "#rr_stub_probe creates a stub Scenario for method when passed a second argument with rr_stub" do
204
- should create_scenario_with_method_name(rr_stub_probe(@subject, :foobar))
219
+ it "#rr_stub.probe creates a stub Scenario for method when passed a second argument with rr_stub" do
220
+ should create_scenario_with_method_name(rr_stub.probe(@subject, :foobar))
205
221
  end
206
222
 
207
223
  it "raises error if passed a method name and a block" do
208
224
  proc do
209
- stub_probe(@object, :foobar) {}
225
+ stub.probe(@object, :foobar) {}
210
226
  end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
211
227
  end
212
228
 
@@ -223,7 +239,7 @@ module Extensions
223
239
  scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
224
240
  scenario.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
225
241
 
226
- @subject.foobar(:something).should == :original_value
242
+ @subject.foobar(1, 2).should == :original_value
227
243
  end
228
244
  end
229
245
 
@@ -239,35 +255,29 @@ module Extensions
239
255
  end
240
256
  end
241
257
 
242
- it "sets up the RR do_not_allow call chain" do
243
- should create_do_not_allow_call_chain(do_not_allow(@subject))
244
- end
245
-
246
- it "sets up the RR do_not_allow call chain with rr_do_not_allow" do
247
- should create_do_not_allow_call_chain(rr_do_not_allow(@subject))
258
+ it "returns a ScenarioCreator when passed no arguments" do
259
+ do_not_allow.should be_instance_of(ScenarioCreator)
248
260
  end
249
261
 
250
262
  it "sets up the RR do_not_allow call chain" do
263
+ should create_do_not_allow_call_chain(do_not_call(@subject))
264
+ should create_do_not_allow_call_chain(rr_do_not_call(@subject))
265
+ should create_do_not_allow_call_chain(dont_call(@subject))
266
+ should create_do_not_allow_call_chain(rr_dont_call(@subject))
267
+ should create_do_not_allow_call_chain(do_not_allow(@subject))
268
+ should create_do_not_allow_call_chain(rr_do_not_allow(@subject))
251
269
  should create_do_not_allow_call_chain(dont_allow(@subject))
252
- end
253
-
254
- it "sets up the RR do_not_allow call chain with rr_do_not_allow" do
255
270
  should create_do_not_allow_call_chain(rr_dont_allow(@subject))
256
271
  end
257
272
 
258
- it "#do_not_allow creates a mock Scenario for method when passed a second argument" do
273
+ it "creates a mock Scenario for method when passed a second argument" do
274
+ should create_scenario_with_method_name(do_not_call(@subject, :foobar))
275
+ should create_scenario_with_method_name(rr_do_not_call(@subject, :foobar))
276
+ should create_scenario_with_method_name(dont_call(@subject, :foobar))
277
+ should create_scenario_with_method_name(rr_dont_call(@subject, :foobar))
259
278
  should create_scenario_with_method_name(do_not_allow(@subject, :foobar))
260
- end
261
-
262
- it "#rr_do_not_allow creates a mock Scenario for method when passed a second argument with rr_mock" do
263
279
  should create_scenario_with_method_name(rr_do_not_allow(@subject, :foobar))
264
- end
265
-
266
- it "#dont_allow creates a mock Scenario for method when passed a second argument" do
267
280
  should create_scenario_with_method_name(dont_allow(@subject, :foobar))
268
- end
269
-
270
- it "#rr_dont_allow creates a mock Scenario for method when passed a second argument with rr_mock" do
271
281
  should create_scenario_with_method_name(rr_dont_allow(@subject, :foobar))
272
282
  end
273
283