rr 0.10.2 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/README.rdoc +1 -0
- data/Rakefile +5 -1
- data/VERSION.yml +1 -1
- data/lib/rr.rb +8 -1
- data/lib/rr/double.rb +18 -78
- data/lib/rr/double_definitions/double_definition_creator_proxy.rb +1 -1
- data/lib/rr/hash_with_object_id_key.rb +1 -3
- data/lib/rr/injections/double_injection.rb +119 -0
- data/lib/rr/injections/injection.rb +22 -0
- data/lib/rr/injections/method_missing_injection.rb +62 -0
- data/lib/rr/injections/singleton_method_added_injection.rb +58 -0
- data/lib/rr/method_dispatches/base_method_dispatch.rb +84 -0
- data/lib/rr/method_dispatches/method_dispatch.rb +58 -0
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +59 -0
- data/lib/rr/space.rb +44 -4
- data/lib/rr/spy_verification_proxy.rb +1 -1
- data/spec/rr/double_injection/double_injection_spec.rb +523 -66
- data/spec/rr/double_injection/double_injection_verify_spec.rb +3 -3
- data/spec/rr/double_spec.rb +18 -18
- data/spec/rr/space/hash_with_object_id_key_spec.rb +1 -1
- data/spec/rr/space/space_spec.rb +250 -64
- data/spec/spec_helper.rb +5 -0
- metadata +9 -7
- data/lib/rr/double_injection.rb +0 -136
- data/spec/rr/double_injection/double_injection_bind_spec.rb +0 -99
- data/spec/rr/double_injection/double_injection_dispatching_spec.rb +0 -244
- data/spec/rr/double_injection/double_injection_has_original_method_spec.rb +0 -58
- data/spec/rr/double_injection/double_injection_reset_spec.rb +0 -72
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
2
|
|
3
3
|
module RR
|
4
|
-
module
|
4
|
+
module Injections
|
5
5
|
describe DoubleInjection, "#verify" do
|
6
6
|
it_should_behave_like "Swapped Space"
|
7
7
|
attr_reader :space, :subject, :method_name, :double_injection
|
@@ -15,7 +15,7 @@ module RR
|
|
15
15
|
it "verifies each double was met" do
|
16
16
|
double = Double.new(
|
17
17
|
double_injection,
|
18
|
-
DoubleDefinition.new(DoubleDefinitions::DoubleDefinitionCreator.new, subject)
|
18
|
+
DoubleDefinitions::DoubleDefinition.new(DoubleDefinitions::DoubleDefinitionCreator.new, subject)
|
19
19
|
)
|
20
20
|
double_injection.register_double double
|
21
21
|
|
@@ -24,6 +24,6 @@ module RR
|
|
24
24
|
subject.foobar(1)
|
25
25
|
lambda {double_injection.verify}.should_not raise_error
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
28
28
|
end
|
29
29
|
end
|
data/spec/rr/double_spec.rb
CHANGED
@@ -41,7 +41,7 @@ module RR
|
|
41
41
|
(class << double; self; end).__send__(:define_method, :puts) do |output|
|
42
42
|
output = output
|
43
43
|
end
|
44
|
-
|
44
|
+
subject.foobar(1, 2)
|
45
45
|
output.should == Double.formatted_name(:foobar, [1, 2])
|
46
46
|
end
|
47
47
|
end
|
@@ -52,7 +52,7 @@ module RR
|
|
52
52
|
(class << double; self; end).__send__(:define_method, :puts) do |output|
|
53
53
|
output = output
|
54
54
|
end
|
55
|
-
|
55
|
+
subject.foobar(1, 2)
|
56
56
|
output.should be_nil
|
57
57
|
end
|
58
58
|
end
|
@@ -60,31 +60,31 @@ module RR
|
|
60
60
|
describe "when implemented by a lambda" do
|
61
61
|
it "calls the return lambda when implemented by a lambda" do
|
62
62
|
double.definition.returns {|arg| "returning #{arg}"}
|
63
|
-
|
63
|
+
subject.foobar(:foobar).should == "returning foobar"
|
64
64
|
end
|
65
65
|
|
66
66
|
it "calls and returns the after_call when after_call is set" do
|
67
67
|
double.definition.returns {|arg| "returning #{arg}"}.after_call do |value|
|
68
68
|
"#{value} after call"
|
69
69
|
end
|
70
|
-
|
70
|
+
subject.foobar(:foobar).should == "returning foobar after call"
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns nil when to returns is not set" do
|
74
|
-
|
74
|
+
subject.foobar.should be_nil
|
75
75
|
end
|
76
76
|
|
77
77
|
it "works when times_called is not set" do
|
78
78
|
double.definition.returns {:value}
|
79
|
-
|
79
|
+
subject.foobar
|
80
80
|
end
|
81
81
|
|
82
82
|
it "verifes the times_called does not exceed the TimesCalledExpectation" do
|
83
83
|
double.definition.times(2).returns {:value}
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
lambda {
|
85
|
+
subject.foobar(:foobar)
|
86
|
+
subject.foobar(:foobar)
|
87
|
+
lambda {subject.foobar(:foobar)}.should raise_error(Errors::TimesCalledError)
|
88
88
|
end
|
89
89
|
|
90
90
|
it "raises DoubleOrderError when ordered and called out of order" do
|
@@ -116,7 +116,7 @@ module RR
|
|
116
116
|
end
|
117
117
|
|
118
118
|
double.definition.returns {:value}.ordered
|
119
|
-
|
119
|
+
subject.foobar(:foobar)
|
120
120
|
verify_ordered_double_called.should be_true
|
121
121
|
passed_in_double.should === double
|
122
122
|
end
|
@@ -131,7 +131,7 @@ module RR
|
|
131
131
|
end
|
132
132
|
|
133
133
|
double.definition.returns {:value}
|
134
|
-
|
134
|
+
subject.foobar(:foobar)
|
135
135
|
verify_ordered_double_called.should be_false
|
136
136
|
end
|
137
137
|
|
@@ -237,7 +237,7 @@ module RR
|
|
237
237
|
context "when TimesCalledExpectation#attempt? is true" do
|
238
238
|
it "returns true" do
|
239
239
|
double.definition.with(1, 2, 3).twice
|
240
|
-
|
240
|
+
subject.foobar(1, 2, 3)
|
241
241
|
double.times_called_expectation.should be_attempt
|
242
242
|
double.should be_attempt
|
243
243
|
end
|
@@ -246,8 +246,8 @@ module RR
|
|
246
246
|
context "when TimesCalledExpectation#attempt? is true" do
|
247
247
|
it "returns false" do
|
248
248
|
double.definition.with(1, 2, 3).twice
|
249
|
-
|
250
|
-
|
249
|
+
subject.foobar(1, 2, 3)
|
250
|
+
subject.foobar(1, 2, 3)
|
251
251
|
double.times_called_expectation.should_not be_attempt
|
252
252
|
double.should_not be_attempt
|
253
253
|
end
|
@@ -269,18 +269,18 @@ module RR
|
|
269
269
|
double.definition.twice.returns {:return_value}
|
270
270
|
|
271
271
|
lambda {double.verify}.should raise_error(Errors::TimesCalledError)
|
272
|
-
|
272
|
+
subject.foobar
|
273
273
|
lambda {double.verify}.should raise_error(Errors::TimesCalledError)
|
274
|
-
|
274
|
+
subject.foobar
|
275
275
|
|
276
276
|
lambda {double.verify}.should_not raise_error
|
277
277
|
end
|
278
278
|
|
279
279
|
it "does not raise an error when there is no times called expectation" do
|
280
280
|
lambda {double.verify}.should_not raise_error
|
281
|
-
|
281
|
+
subject.foobar
|
282
282
|
lambda {double.verify}.should_not raise_error
|
283
|
-
|
283
|
+
subject.foobar
|
284
284
|
lambda {double.verify}.should_not raise_error
|
285
285
|
end
|
286
286
|
end
|
data/spec/rr/space/space_spec.rb
CHANGED
@@ -12,7 +12,10 @@ module RR
|
|
12
12
|
describe ".method_missing" do
|
13
13
|
it "proxies to a singleton instance of Space" do
|
14
14
|
create_double_args = nil
|
15
|
-
(
|
15
|
+
(
|
16
|
+
class << space;
|
17
|
+
self;
|
18
|
+
end).class_eval do
|
16
19
|
define_method :double_injection do |*args|
|
17
20
|
create_double_args = args
|
18
21
|
end
|
@@ -22,16 +25,16 @@ module RR
|
|
22
25
|
create_double_args.should == [:foo, :bar]
|
23
26
|
end
|
24
27
|
end
|
25
|
-
|
28
|
+
|
26
29
|
describe "#record_call" do
|
27
|
-
it "should add a call to the list"
|
30
|
+
it "should add a call to the list" do
|
28
31
|
object = Object.new
|
29
32
|
block = lambda {}
|
30
|
-
space.record_call(object
|
31
|
-
space.recorded_calls.should == RR::RecordedCalls.new([[object
|
33
|
+
space.record_call(object, :to_s, [], block)
|
34
|
+
space.recorded_calls.should == RR::RecordedCalls.new([[object, :to_s, [], block]])
|
32
35
|
end
|
33
36
|
end
|
34
|
-
|
37
|
+
|
35
38
|
describe "#double_injection" do
|
36
39
|
context "when existing subject == but not === with the same method name" do
|
37
40
|
it "creates a new DoubleInjection" do
|
@@ -40,24 +43,25 @@ module RR
|
|
40
43
|
(subject_1 === subject_2).should be_true
|
41
44
|
subject_1.__id__.should_not == subject_2.__id__
|
42
45
|
|
43
|
-
|
44
|
-
|
46
|
+
injection_1 = space.double_injection(subject_1, :foobar)
|
47
|
+
injection_2 = space.double_injection(subject_2, :foobar)
|
45
48
|
|
46
|
-
|
49
|
+
injection_1.should_not == injection_2
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
|
-
context "when
|
53
|
+
context "when a DoubleInjection is not registered for the subject and method_name" do
|
51
54
|
before do
|
52
55
|
def subject.foobar(*args)
|
53
56
|
:original_foobar
|
54
57
|
end
|
58
|
+
|
55
59
|
@method_name = :foobar
|
56
60
|
end
|
57
61
|
|
58
62
|
context "when method_name is a symbol" do
|
59
63
|
it "returns double_injection and adds double_injection to double_injection list" do
|
60
|
-
|
64
|
+
double_injection = space.double_injection(subject, method_name)
|
61
65
|
space.double_injection(subject, method_name).should === double_injection
|
62
66
|
double_injection.subject.should === subject
|
63
67
|
double_injection.method_name.should === method_name
|
@@ -66,7 +70,7 @@ module RR
|
|
66
70
|
|
67
71
|
context "when method_name is a string" do
|
68
72
|
it "returns double_injection and adds double_injection to double_injection list" do
|
69
|
-
|
73
|
+
double_injection = space.double_injection(subject, 'foobar')
|
70
74
|
space.double_injection(subject, method_name).should === double_injection
|
71
75
|
double_injection.subject.should === subject
|
72
76
|
double_injection.method_name.should === method_name
|
@@ -75,7 +79,7 @@ module RR
|
|
75
79
|
|
76
80
|
it "overrides the method when passing a block" do
|
77
81
|
original_method = subject.method(:foobar)
|
78
|
-
|
82
|
+
space.double_injection(subject, method_name)
|
79
83
|
subject.method(:foobar).should_not == original_method
|
80
84
|
end
|
81
85
|
end
|
@@ -85,19 +89,121 @@ module RR
|
|
85
89
|
def subject.foobar(*args)
|
86
90
|
:original_foobar
|
87
91
|
end
|
92
|
+
|
88
93
|
@method_name = :foobar
|
89
94
|
end
|
90
95
|
|
91
|
-
|
92
|
-
|
93
|
-
|
96
|
+
context "when a DoubleInjection is registered for the subject and method_name" do
|
97
|
+
it "returns the existing DoubleInjection" do
|
98
|
+
@double_injection = space.double_injection(subject, 'foobar')
|
99
|
+
|
100
|
+
double_injection.subject_has_original_method?.should be_true
|
101
|
+
|
102
|
+
space.double_injection(subject, 'foobar').should === double_injection
|
103
|
+
|
104
|
+
double_injection.reset
|
105
|
+
subject.foobar.should == :original_foobar
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#method_missing_injection" do
|
112
|
+
context "when existing subject == but not === with the same method name" do
|
113
|
+
it "creates a new DoubleInjection" do
|
114
|
+
subject_1 = []
|
115
|
+
subject_2 = []
|
116
|
+
(subject_1 === subject_2).should be_true
|
117
|
+
subject_1.__id__.should_not == subject_2.__id__
|
118
|
+
|
119
|
+
injection_1 = space.method_missing_injection(subject_1)
|
120
|
+
injection_2 = space.method_missing_injection(subject_2)
|
121
|
+
|
122
|
+
injection_1.should_not == injection_2
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "when a MethodMissingInjection is not registered for the subject and method_name" do
|
127
|
+
before do
|
128
|
+
def subject.method_missing(method_name, *args, &block)
|
129
|
+
:original_method_missing
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "overrides the method when passing a block" do
|
134
|
+
original_method = subject.method(:method_missing)
|
135
|
+
space.method_missing_injection(subject)
|
136
|
+
subject.method(:method_missing).should_not == original_method
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "when a MethodMissingInjection is registered for the subject and method_name" do
|
141
|
+
before do
|
142
|
+
def subject.method_missing(method_name, *args, &block)
|
143
|
+
:original_method_missing
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "when a DoubleInjection is registered for the subject and method_name" do
|
148
|
+
it "returns the existing DoubleInjection" do
|
149
|
+
injection = space.method_missing_injection(subject)
|
150
|
+
injection.subject_has_original_method?.should be_true
|
151
|
+
|
152
|
+
space.method_missing_injection(subject).should === injection
|
153
|
+
|
154
|
+
injection.reset
|
155
|
+
subject.method_missing(:foobar).should == :original_method_missing
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "#singleton_method_added_injection" do
|
162
|
+
context "when existing subject == but not === with the same method name" do
|
163
|
+
it "creates a new DoubleInjection" do
|
164
|
+
subject_1 = []
|
165
|
+
subject_2 = []
|
166
|
+
(subject_1 === subject_2).should be_true
|
167
|
+
subject_1.__id__.should_not == subject_2.__id__
|
168
|
+
|
169
|
+
injection_1 = space.singleton_method_added_injection(subject_1)
|
170
|
+
injection_2 = space.singleton_method_added_injection(subject_2)
|
171
|
+
|
172
|
+
injection_1.should_not == injection_2
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "when a SingletonMethodAddedInjection is not registered for the subject and method_name" do
|
177
|
+
before do
|
178
|
+
def subject.singleton_method_added(method_name)
|
179
|
+
:original_singleton_method_added
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
it "overrides the method when passing a block" do
|
184
|
+
original_method = subject.method(:singleton_method_added)
|
185
|
+
space.singleton_method_added_injection(subject)
|
186
|
+
subject.method(:singleton_method_added).should_not == original_method
|
187
|
+
end
|
188
|
+
end
|
94
189
|
|
95
|
-
|
190
|
+
context "when a SingletonMethodAddedInjection is registered for the subject and method_name" do
|
191
|
+
before do
|
192
|
+
def subject.singleton_method_added(method_name)
|
193
|
+
:original_singleton_method_added
|
194
|
+
end
|
195
|
+
end
|
96
196
|
|
97
|
-
|
197
|
+
context "when a DoubleInjection is registered for the subject and method_name" do
|
198
|
+
it "returns the existing DoubleInjection" do
|
199
|
+
injection = space.singleton_method_added_injection(subject)
|
200
|
+
injection.subject_has_original_method?.should be_true
|
98
201
|
|
99
|
-
|
100
|
-
|
202
|
+
space.singleton_method_added_injection(subject).should === injection
|
203
|
+
|
204
|
+
injection.reset
|
205
|
+
subject.singleton_method_added(:foobar).should == :original_singleton_method_added
|
206
|
+
end
|
101
207
|
end
|
102
208
|
end
|
103
209
|
end
|
@@ -109,11 +215,11 @@ module RR
|
|
109
215
|
@subject_2 = Object.new
|
110
216
|
@method_name = :foobar
|
111
217
|
end
|
112
|
-
|
218
|
+
|
113
219
|
it "should clear the #recorded_calls" do
|
114
220
|
object = Object.new
|
115
|
-
space.record_call(object
|
116
|
-
|
221
|
+
space.record_call(object, :to_s, [], nil)
|
222
|
+
|
117
223
|
space.reset
|
118
224
|
space.recorded_calls.should == RR::RecordedCalls.new([])
|
119
225
|
end
|
@@ -137,36 +243,73 @@ module RR
|
|
137
243
|
end
|
138
244
|
|
139
245
|
it "resets all double_injections" do
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
double_2 = space.double_injection(subject_2, method_name)
|
151
|
-
double_2_reset_call_count = 0
|
152
|
-
(
|
153
|
-
class << double_2;
|
154
|
-
self;
|
155
|
-
end).class_eval do
|
156
|
-
define_method(:reset) do ||
|
157
|
-
double_2_reset_call_count += 1
|
158
|
-
end
|
159
|
-
end
|
246
|
+
subject_1.respond_to?(method_name).should be_false
|
247
|
+
subject_2.respond_to?(method_name).should be_false
|
248
|
+
|
249
|
+
space.double_injection(subject_1, method_name)
|
250
|
+
space.double_injection_exists?(subject_1, method_name).should be_true
|
251
|
+
subject_1.respond_to?(method_name).should be_true
|
252
|
+
|
253
|
+
space.double_injection(subject_2, method_name)
|
254
|
+
space.double_injection_exists?(subject_2, method_name).should be_true
|
255
|
+
subject_2.respond_to?(method_name).should be_true
|
160
256
|
|
161
257
|
space.reset
|
162
|
-
|
163
|
-
|
258
|
+
|
259
|
+
subject_1.respond_to?(method_name).should be_false
|
260
|
+
space.double_injection_exists?(subject_1, method_name).should be_false
|
261
|
+
|
262
|
+
subject_2.respond_to?(method_name).should be_false
|
263
|
+
space.double_injection_exists?(subject_2, method_name).should be_false
|
264
|
+
end
|
265
|
+
|
266
|
+
it "resets all method_missing_injections" do
|
267
|
+
subject_1.respond_to?(:method_missing).should be_false
|
268
|
+
subject_2.respond_to?(:method_missing).should be_false
|
269
|
+
|
270
|
+
space.method_missing_injection(subject_1)
|
271
|
+
space.method_missing_injection_exists?(subject_1).should be_true
|
272
|
+
subject_1.respond_to?(:method_missing).should be_true
|
273
|
+
|
274
|
+
space.method_missing_injection(subject_2)
|
275
|
+
space.method_missing_injection_exists?(subject_2).should be_true
|
276
|
+
subject_2.respond_to?(:method_missing).should be_true
|
277
|
+
|
278
|
+
space.reset
|
279
|
+
|
280
|
+
subject_1.respond_to?(:method_missing).should be_false
|
281
|
+
space.method_missing_injection_exists?(subject_1).should be_false
|
282
|
+
|
283
|
+
subject_2.respond_to?(:method_missing).should be_false
|
284
|
+
space.method_missing_injection_exists?(subject_2).should be_false
|
285
|
+
end
|
286
|
+
|
287
|
+
it "resets all singleton_method_added_injections" do
|
288
|
+
subject_1.respond_to?(:singleton_method_added).should be_false
|
289
|
+
subject_2.respond_to?(:singleton_method_added).should be_false
|
290
|
+
|
291
|
+
space.singleton_method_added_injection(subject_1)
|
292
|
+
space.singleton_method_added_injection_exists?(subject_1).should be_true
|
293
|
+
subject_1.respond_to?(:singleton_method_added).should be_true
|
294
|
+
|
295
|
+
space.singleton_method_added_injection(subject_2)
|
296
|
+
space.singleton_method_added_injection_exists?(subject_2).should be_true
|
297
|
+
subject_2.respond_to?(:singleton_method_added).should be_true
|
298
|
+
|
299
|
+
space.reset
|
300
|
+
|
301
|
+
subject_1.respond_to?(:singleton_method_added).should be_false
|
302
|
+
space.singleton_method_added_injection_exists?(subject_1).should be_false
|
303
|
+
|
304
|
+
subject_2.respond_to?(:singleton_method_added).should be_false
|
305
|
+
space.singleton_method_added_injection_exists?(subject_2).should be_false
|
164
306
|
end
|
165
307
|
end
|
166
308
|
|
167
309
|
describe "#reset_double" do
|
168
310
|
before do
|
169
311
|
@method_name = :foobar
|
312
|
+
|
170
313
|
def subject.foobar
|
171
314
|
end
|
172
315
|
end
|
@@ -214,14 +357,20 @@ module RR
|
|
214
357
|
it "resets the double_injection and removes it from the double_injections list" do
|
215
358
|
double_injection_1 = space.double_injection(subject_1, method_name)
|
216
359
|
double_1_reset_call_count = 0
|
217
|
-
(
|
360
|
+
(
|
361
|
+
class << double_injection_1;
|
362
|
+
self;
|
363
|
+
end).class_eval do
|
218
364
|
define_method(:reset) do
|
219
365
|
double_1_reset_call_count += 1
|
220
366
|
end
|
221
367
|
end
|
222
368
|
double_injection_2 = space.double_injection(subject_2, method_name)
|
223
369
|
double_2_reset_call_count = 0
|
224
|
-
(
|
370
|
+
(
|
371
|
+
class << double_injection_2;
|
372
|
+
self;
|
373
|
+
end).class_eval do
|
225
374
|
define_method(:reset) do
|
226
375
|
double_2_reset_call_count += 1
|
227
376
|
end
|
@@ -268,7 +417,10 @@ module RR
|
|
268
417
|
it "verifies and deletes the double_injections" do
|
269
418
|
double_1_verify_call_count = 0
|
270
419
|
double_1_reset_call_count = 0
|
271
|
-
(
|
420
|
+
(
|
421
|
+
class << double_1;
|
422
|
+
self;
|
423
|
+
end).class_eval do
|
272
424
|
define_method(:verify) do
|
273
425
|
double_1_verify_call_count += 1
|
274
426
|
end
|
@@ -279,7 +431,10 @@ module RR
|
|
279
431
|
|
280
432
|
double_2_verify_call_count = 0
|
281
433
|
double_2_reset_call_count = 0
|
282
|
-
(
|
434
|
+
(
|
435
|
+
class << double_2;
|
436
|
+
self;
|
437
|
+
end).class_eval do
|
283
438
|
define_method(:verify) do
|
284
439
|
double_2_verify_call_count += 1
|
285
440
|
end
|
@@ -300,7 +455,10 @@ module RR
|
|
300
455
|
it "verifies all Doubles injected into the Object" do
|
301
456
|
double_1_verify_call_count = 0
|
302
457
|
double_1_reset_call_count = 0
|
303
|
-
(
|
458
|
+
(
|
459
|
+
class << double_1;
|
460
|
+
self;
|
461
|
+
end).class_eval do
|
304
462
|
define_method(:verify) do
|
305
463
|
double_1_verify_call_count += 1
|
306
464
|
end
|
@@ -311,7 +469,10 @@ module RR
|
|
311
469
|
|
312
470
|
double_2_verify_call_count = 0
|
313
471
|
double_2_reset_call_count = 0
|
314
|
-
(
|
472
|
+
(
|
473
|
+
class << double_2;
|
474
|
+
self;
|
475
|
+
end).class_eval do
|
315
476
|
define_method(:verify) do
|
316
477
|
double_2_verify_call_count += 1
|
317
478
|
end
|
@@ -333,7 +494,10 @@ module RR
|
|
333
494
|
it "verifies the Doubles injected into all of the Objects" do
|
334
495
|
double_1_verify_call_count = 0
|
335
496
|
double_1_reset_call_count = 0
|
336
|
-
(
|
497
|
+
(
|
498
|
+
class << double_1;
|
499
|
+
self;
|
500
|
+
end).class_eval do
|
337
501
|
define_method(:verify) do
|
338
502
|
double_1_verify_call_count += 1
|
339
503
|
end
|
@@ -344,7 +508,10 @@ module RR
|
|
344
508
|
|
345
509
|
double_2_verify_call_count = 0
|
346
510
|
double_2_reset_call_count = 0
|
347
|
-
(
|
511
|
+
(
|
512
|
+
class << double_2;
|
513
|
+
self;
|
514
|
+
end).class_eval do
|
348
515
|
define_method(:verify) do
|
349
516
|
double_2_verify_call_count += 1
|
350
517
|
end
|
@@ -355,7 +522,10 @@ module RR
|
|
355
522
|
|
356
523
|
double3_verify_call_count = 0
|
357
524
|
double3_reset_call_count = 0
|
358
|
-
(
|
525
|
+
(
|
526
|
+
class << double3;
|
527
|
+
self;
|
528
|
+
end).class_eval do
|
359
529
|
define_method(:verify) do
|
360
530
|
double3_verify_call_count += 1
|
361
531
|
end
|
@@ -379,7 +549,10 @@ module RR
|
|
379
549
|
it "does not raise an error" do
|
380
550
|
double_1_verify_call_count = 0
|
381
551
|
double_1_reset_call_count = 0
|
382
|
-
(
|
552
|
+
(
|
553
|
+
class << double_1;
|
554
|
+
self;
|
555
|
+
end).class_eval do
|
383
556
|
define_method(:verify) do
|
384
557
|
double_1_verify_call_count += 1
|
385
558
|
end
|
@@ -390,7 +563,10 @@ module RR
|
|
390
563
|
|
391
564
|
double_2_verify_call_count = 0
|
392
565
|
double_2_reset_call_count = 0
|
393
|
-
(
|
566
|
+
(
|
567
|
+
class << double_2;
|
568
|
+
self;
|
569
|
+
end).class_eval do
|
394
570
|
define_method(:verify) do
|
395
571
|
double_2_verify_call_count += 1
|
396
572
|
end
|
@@ -401,7 +577,10 @@ module RR
|
|
401
577
|
|
402
578
|
double3_verify_call_count = 0
|
403
579
|
double3_reset_call_count = 0
|
404
|
-
(
|
580
|
+
(
|
581
|
+
class << double3;
|
582
|
+
self;
|
583
|
+
end).class_eval do
|
405
584
|
define_method(:verify) do
|
406
585
|
double3_verify_call_count += 1
|
407
586
|
end
|
@@ -426,6 +605,7 @@ module RR
|
|
426
605
|
describe "#verify_double" do
|
427
606
|
before do
|
428
607
|
@method_name = :foobar
|
608
|
+
|
429
609
|
def subject.foobar
|
430
610
|
end
|
431
611
|
end
|
@@ -435,7 +615,10 @@ module RR
|
|
435
615
|
space.double_injections[subject][method_name].should === double_injection
|
436
616
|
|
437
617
|
verify_call_count = 0
|
438
|
-
(
|
618
|
+
(
|
619
|
+
class << double_injection;
|
620
|
+
self;
|
621
|
+
end).class_eval do
|
439
622
|
define_method(:verify) do
|
440
623
|
verify_call_count += 1
|
441
624
|
end
|
@@ -456,7 +639,10 @@ module RR
|
|
456
639
|
space.double_injections[subject][method_name].should === double_injection
|
457
640
|
|
458
641
|
verify_called = true
|
459
|
-
(
|
642
|
+
(
|
643
|
+
class << double_injection;
|
644
|
+
self;
|
645
|
+
end).class_eval do
|
460
646
|
define_method(:verify) do
|
461
647
|
verify_called = true
|
462
648
|
raise "An Error"
|
@@ -488,8 +674,8 @@ module RR
|
|
488
674
|
lambda do
|
489
675
|
space.verify_ordered_double(double)
|
490
676
|
end.should raise_error(
|
491
|
-
|
492
|
-
|
677
|
+
Errors::DoubleOrderError,
|
678
|
+
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation"
|
493
679
|
)
|
494
680
|
end
|
495
681
|
end
|
@@ -533,8 +719,8 @@ module RR
|
|
533
719
|
end.should raise_error(
|
534
720
|
Errors::DoubleOrderError,
|
535
721
|
"foobar() called out of order in list\n" <<
|
536
|
-
|
537
|
-
|
722
|
+
"- foobar()\n" <<
|
723
|
+
"- foobar()"
|
538
724
|
)
|
539
725
|
end
|
540
726
|
|
@@ -547,4 +733,4 @@ module RR
|
|
547
733
|
end
|
548
734
|
end
|
549
735
|
end
|
550
|
-
end
|
736
|
+
end
|