rr 1.0.4 → 1.0.5.rc1
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.
- checksums.yaml +15 -0
- data/CHANGES.md +376 -0
- data/Gemfile +7 -10
- data/README.md +822 -0
- data/Rakefile +24 -78
- data/VERSION +1 -0
- data/lib/rr.rb +3 -0
- data/lib/rr/adapters/minitest.rb +6 -0
- data/lib/rr/adapters/rr_methods.rb +6 -10
- data/lib/rr/adapters/rspec.rb +3 -0
- data/lib/rr/adapters/rspec2.rb +30 -0
- data/lib/rr/adapters/test_unit.rb +2 -0
- data/lib/rr/double.rb +3 -2
- data/lib/rr/double_definitions/child_double_definition_create.rb +3 -2
- data/lib/rr/double_definitions/double_definition.rb +15 -13
- data/lib/rr/double_definitions/double_definition_create.rb +9 -5
- data/lib/rr/double_definitions/double_injections/any_instance_of.rb +3 -2
- data/lib/rr/double_definitions/strategies/strategy.rb +5 -4
- data/lib/rr/double_definitions/strategies/strategy_methods.rb +6 -8
- data/lib/rr/double_definitions/strategies/verification/mock.rb +3 -3
- data/lib/rr/double_matches.rb +2 -1
- data/lib/rr/expectations/argument_equality_expectation.rb +2 -2
- data/lib/rr/expectations/times_called_expectation.rb +2 -2
- data/lib/rr/injections/double_injection.rb +12 -11
- data/lib/rr/injections/injection.rb +2 -2
- data/lib/rr/injections/method_missing_injection.rb +21 -7
- data/lib/rr/injections/singleton_method_added_injection.rb +3 -1
- data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
- data/lib/rr/method_dispatches/method_dispatch.rb +2 -1
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +2 -1
- data/lib/rr/proc_from_block.rb +8 -4
- data/lib/rr/space.rb +3 -2
- data/lib/rr/times_called_matchers/times_called_matcher.rb +2 -2
- data/lib/rr/version.rb +5 -0
- data/lib/rr/wildcard_matchers/boolean.rb +2 -2
- data/spec/runner.rb +41 -0
- metadata +45 -133
- data/.gitignore +0 -10
- data/.runrc +0 -3
- data/.rvmrc +0 -2
- data/CHANGES +0 -266
- data/Gemfile.lock +0 -31
- data/README.rdoc +0 -392
- data/benchmarks/rr_benchmark.rb +0 -32
- data/benchmarks/rspec_benchmark.rb +0 -14
- data/doc/0.6.0.release.markdown +0 -81
- data/doc/todo.txt +0 -0
- data/introducting_rr.txt +0 -206
- data/rr.gemspec +0 -37
- data/spec/api/any_instance_of/all_instances_of_spec.rb +0 -12
- data/spec/api/any_instance_of/any_instance_of_spec.rb +0 -47
- data/spec/api/any_instance_of/instance_of_spec.rb +0 -12
- data/spec/api/dont_allow/dont_allow_after_stub_spec.rb +0 -14
- data/spec/api/mock/mock_spec.rb +0 -193
- data/spec/api/proxy/proxy_spec.rb +0 -86
- data/spec/api/spy/spy_spec.rb +0 -49
- data/spec/api/strong/strong_spec.rb +0 -87
- data/spec/api/stub/stub_spec.rb +0 -152
- data/spec/core_spec_suite.rb +0 -19
- data/spec/environment_fixture_setup.rb +0 -8
- data/spec/minitest_spec_suite.rb +0 -21
- data/spec/proc_from_block_spec.rb +0 -14
- data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +0 -67
- data/spec/rr/adapters/rr_methods_creator_spec.rb +0 -137
- data/spec/rr/adapters/rr_methods_space_spec.rb +0 -98
- data/spec/rr/adapters/rr_methods_spec_helper.rb +0 -11
- data/spec/rr/adapters/rr_methods_times_matcher_spec.rb +0 -13
- data/spec/rr/double_definitions/child_double_definition_creator_spec.rb +0 -112
- data/spec/rr/double_definitions/double_definition_create_blank_slate_spec.rb +0 -91
- data/spec/rr/double_definitions/double_definition_create_spec.rb +0 -443
- data/spec/rr/double_injection/double_injection_spec.rb +0 -546
- data/spec/rr/double_injection/double_injection_verify_spec.rb +0 -29
- data/spec/rr/errors/rr_error_spec.rb +0 -67
- data/spec/rr/expectations/any_argument_expectation_spec.rb +0 -47
- data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +0 -14
- data/spec/rr/expectations/argument_equality_expectation_spec.rb +0 -135
- data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +0 -34
- data/spec/rr/expectations/hash_including_argument_equality_expectation_spec.rb +0 -82
- data/spec/rr/expectations/hash_including_spec.rb +0 -17
- data/spec/rr/expectations/satisfy_argument_equality_expectation_spec.rb +0 -59
- data/spec/rr/expectations/satisfy_spec.rb +0 -14
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +0 -22
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +0 -37
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +0 -43
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +0 -15
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +0 -58
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +0 -35
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +0 -39
- data/spec/rr/minitest/minitest_integration_test.rb +0 -59
- data/spec/rr/minitest/test_helper.rb +0 -7
- data/spec/rr/rspec/invocation_matcher_spec.rb +0 -279
- data/spec/rr/rspec/rspec_adapter_spec.rb +0 -63
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +0 -31
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec_fixture.rb +0 -11
- data/spec/rr/rspec/rspec_usage_spec.rb +0 -86
- data/spec/rr/space/hash_with_object_id_key_spec.rb +0 -88
- data/spec/rr/space/space_spec.rb +0 -596
- data/spec/rr/test_unit/test_helper.rb +0 -7
- data/spec/rr/test_unit/test_unit_backtrace_test.rb +0 -36
- data/spec/rr/test_unit/test_unit_integration_test.rb +0 -59
- data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +0 -47
- data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/integer_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/proc_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/range_matcher_spec.rb +0 -76
- data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +0 -118
- data/spec/rr/wildcard_matchers/anything_spec.rb +0 -24
- data/spec/rr/wildcard_matchers/boolean_spec.rb +0 -36
- data/spec/rr/wildcard_matchers/duck_type_spec.rb +0 -52
- data/spec/rr/wildcard_matchers/is_a_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/numeric_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/range_spec.rb +0 -35
- data/spec/rr/wildcard_matchers/regexp_spec.rb +0 -43
- data/spec/rr_spec.rb +0 -28
- data/spec/rspec_spec_suite.rb +0 -17
- data/spec/spec.opts +0 -10
- data/spec/spec_helper.rb +0 -41
- data/spec/spec_suite.rb +0 -54
- data/spec/spy_verification_spec.rb +0 -129
- data/spec/test_unit_spec_suite.rb +0 -21
@@ -1,443 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module DoubleDefinitions
|
5
|
-
describe DoubleDefinitionCreate do
|
6
|
-
attr_reader :double_definition_create, :subject, :strategy_method_name
|
7
|
-
it_should_behave_like "Swapped Space"
|
8
|
-
before(:each) do
|
9
|
-
@subject = Object.new
|
10
|
-
@double_definition_create = DoubleDefinitionCreate.new
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#root_subject" do
|
14
|
-
it "returns #subject" do
|
15
|
-
double_definition_create.stub(subject).foobar
|
16
|
-
double_definition_create.root_subject.should == subject
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "StrategySetupMethods" do
|
21
|
-
describe "normal strategy definitions" do
|
22
|
-
def call_strategy(*args, &block)
|
23
|
-
double_definition_create.__send__(strategy_method_name, *args, &block)
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#mock" do
|
27
|
-
before do
|
28
|
-
@strategy_method_name = :mock
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when passing no args" do
|
32
|
-
it "returns self" do
|
33
|
-
call_strategy.should === double_definition_create
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when passed a subject and a method_name argument" do
|
38
|
-
it "creates a mock Double for method" do
|
39
|
-
double_definition = double_definition_create.mock(subject, :foobar).returns {:baz}
|
40
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::IntegerMatcher.new(1)
|
41
|
-
double_definition.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
42
|
-
double_definition.argument_expectation.expected_arguments.should == []
|
43
|
-
subject.foobar.should == :baz
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#stub" do
|
49
|
-
before do
|
50
|
-
@strategy_method_name = :stub
|
51
|
-
end
|
52
|
-
|
53
|
-
context "when passing no args" do
|
54
|
-
it "returns self" do
|
55
|
-
call_strategy.should === double_definition_create
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when passed subject and a method_name argument" do
|
60
|
-
it "creates a stub Double for method when passed a method_name argument" do
|
61
|
-
double_definition = double_definition_create.stub(subject, :foobar).returns {:baz}
|
62
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
63
|
-
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
64
|
-
subject.foobar.should == :baz
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "#dont_allow" do
|
70
|
-
before do
|
71
|
-
@strategy_method_name = :dont_allow
|
72
|
-
end
|
73
|
-
|
74
|
-
context "when passing no args" do
|
75
|
-
it "returns self" do
|
76
|
-
call_strategy.should === double_definition_create
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when passed a subject and a method_name argument_expectation" do
|
81
|
-
it "creates a mock Double for method" do
|
82
|
-
double_definition = double_definition_create.dont_allow(subject, :foobar)
|
83
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::NeverMatcher.new
|
84
|
-
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
85
|
-
|
86
|
-
lambda do
|
87
|
-
subject.foobar
|
88
|
-
end.should raise_error(RR::Errors::TimesCalledError)
|
89
|
-
RR.reset
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "! strategy definitions" do
|
96
|
-
attr_reader :strategy_method_name
|
97
|
-
def call_strategy(*args, &definition_eval_block)
|
98
|
-
double_definition_create.__send__(strategy_method_name, *args, &definition_eval_block)
|
99
|
-
end
|
100
|
-
|
101
|
-
describe "#mock!" do
|
102
|
-
before do
|
103
|
-
@strategy_method_name = :mock!
|
104
|
-
end
|
105
|
-
|
106
|
-
context "when passed a method_name argument" do
|
107
|
-
it "sets #verification_strategy to Mock" do
|
108
|
-
double_definition_create.mock!(:foobar)
|
109
|
-
double_definition_create.verification_strategy.class.should == Strategies::Verification::Mock
|
110
|
-
lambda {RR.verify}.should raise_error(::RR::Errors::TimesCalledError)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "#stub!" do
|
116
|
-
before do
|
117
|
-
@strategy_method_name = :stub!
|
118
|
-
end
|
119
|
-
|
120
|
-
context "when passed a method_name argument" do
|
121
|
-
it "sets #verification_strategy to Stub" do
|
122
|
-
double_definition_create.stub!(:foobar)
|
123
|
-
double_definition_create.verification_strategy.class.should == Strategies::Verification::Stub
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "#dont_allow!" do
|
129
|
-
before do
|
130
|
-
@strategy_method_name = :dont_allow!
|
131
|
-
end
|
132
|
-
|
133
|
-
context "when passed a method_name argument" do
|
134
|
-
it "sets #verification_strategy to DontAllow" do
|
135
|
-
double_definition_create.dont_allow!(:foobar)
|
136
|
-
double_definition_create.verification_strategy.class.should == Strategies::Verification::DontAllow
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "#stub.proxy" do
|
143
|
-
before do
|
144
|
-
class << subject
|
145
|
-
def foobar(*args)
|
146
|
-
:original_foobar
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context "when passed a method_name argument" do
|
152
|
-
it "creates a proxy Double for method" do
|
153
|
-
double_definition = double_definition_create.stub.proxy(subject, :foobar).after_call {:baz}
|
154
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
155
|
-
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
156
|
-
subject.foobar.should == :baz
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
describe "#instance_of" do
|
162
|
-
context "when not passed a class" do
|
163
|
-
it "raises an ArgumentError" do
|
164
|
-
lambda do
|
165
|
-
double_definition_create.instance_of(Object.new).foobar
|
166
|
-
end.should raise_error(ArgumentError, "instance_of only accepts class objects")
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
context "when passed a method_name argument" do
|
171
|
-
it "creates a proxy Double for method" do
|
172
|
-
klass = Class.new
|
173
|
-
double_definition = double_definition_create.stub.instance_of(klass, :foobar).returns {:baz}
|
174
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
175
|
-
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
176
|
-
klass.new.foobar.should == :baz
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe "#instance_of.mock" do
|
182
|
-
before do
|
183
|
-
@klass = Class.new
|
184
|
-
end
|
185
|
-
|
186
|
-
# context "when passed no arguments" do
|
187
|
-
# it "returns a DoubleDefinitiondouble_definition_create" do
|
188
|
-
# instance_of.instance_of.should be_instance_of(DoubleDefinitionCreate)
|
189
|
-
# end
|
190
|
-
# end
|
191
|
-
|
192
|
-
context "when passed a method_name argument" do
|
193
|
-
it "creates a instance_of Double for method" do
|
194
|
-
double_definition = instance_of.mock(@klass, :foobar)
|
195
|
-
double_definition.with(1, 2) {:baz}
|
196
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::IntegerMatcher.new(1)
|
197
|
-
double_definition.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
198
|
-
double_definition.argument_expectation.expected_arguments.should == [1, 2]
|
199
|
-
|
200
|
-
@klass.new.foobar(1, 2).should == :baz
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
describe "StrategyExecutionMethods" do
|
207
|
-
describe "#create" do
|
208
|
-
context "when #verification_strategy is a Mock" do
|
209
|
-
context "when #implementation_strategy is a Reimplementation" do
|
210
|
-
before do
|
211
|
-
double_definition_create.mock(subject)
|
212
|
-
end
|
213
|
-
|
214
|
-
it "sets expectation on the #subject that it will be sent the method_name once with the passed-in arguments" do
|
215
|
-
mock(subject).foobar(1, 2)
|
216
|
-
subject.foobar(1, 2)
|
217
|
-
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
218
|
-
lambda {RR.verify}.should raise_error(RR::Errors::TimesCalledError)
|
219
|
-
end
|
220
|
-
|
221
|
-
describe "#subject.method_name being called" do
|
222
|
-
it "returns the return value of the Double#returns block" do
|
223
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
224
|
-
subject.foobar(1, 2).should == :baz
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
context "when #implementation_strategy is a Proxy" do
|
230
|
-
before do
|
231
|
-
double_definition_create.mock
|
232
|
-
double_definition_create.proxy(subject)
|
233
|
-
end
|
234
|
-
|
235
|
-
it "sets expectation on the #subject that it will be sent the method_name once with the passed-in arguments" do
|
236
|
-
def subject.foobar(*args)
|
237
|
-
:baz
|
238
|
-
end
|
239
|
-
mock(subject).foobar(1, 2)
|
240
|
-
|
241
|
-
subject.foobar(1, 2)
|
242
|
-
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
243
|
-
lambda {RR.verify}.should raise_error(RR::Errors::TimesCalledError)
|
244
|
-
end
|
245
|
-
|
246
|
-
describe "#subject.method_name being called" do
|
247
|
-
it "calls the original method" do
|
248
|
-
original_method_called = false
|
249
|
-
(class << subject; self; end).class_eval do
|
250
|
-
define_method(:foobar) do |*args|
|
251
|
-
original_method_called = true
|
252
|
-
end
|
253
|
-
end
|
254
|
-
double_definition_create.call(:foobar, 1, 2)
|
255
|
-
subject.foobar(1, 2)
|
256
|
-
original_method_called.should be_true
|
257
|
-
end
|
258
|
-
|
259
|
-
context "when not passed a block" do
|
260
|
-
it "returns the value of the original method" do
|
261
|
-
def subject.foobar(*args)
|
262
|
-
:baz;
|
263
|
-
end
|
264
|
-
double_definition_create.call(:foobar, 1, 2)
|
265
|
-
subject.foobar(1, 2).should == :baz
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
context "when passed a block" do
|
270
|
-
attr_reader :real_value
|
271
|
-
before do
|
272
|
-
@real_value = real_value = Object.new
|
273
|
-
(class << subject; self; end).class_eval do
|
274
|
-
define_method(:foobar) {|arg1, arg2| real_value}
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
it "calls the block with the return value of the original method" do
|
279
|
-
double_definition_create.call(:foobar, 1, 2) do |value|
|
280
|
-
mock(value).a_method {99}
|
281
|
-
value
|
282
|
-
end
|
283
|
-
subject.foobar(1, 2)
|
284
|
-
real_value.a_method.should == 99
|
285
|
-
end
|
286
|
-
|
287
|
-
it "returns the return value of the block" do
|
288
|
-
double_definition_create.call(:foobar, 1, 2) do |value|
|
289
|
-
:something_else
|
290
|
-
end
|
291
|
-
subject.foobar(1, 2).should == :something_else
|
292
|
-
end
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
context "when #verification_strategy is a Stub" do
|
299
|
-
context "when #implementation_strategy is a Reimplementation" do
|
300
|
-
before do
|
301
|
-
double_definition_create.stub(subject)
|
302
|
-
end
|
303
|
-
|
304
|
-
context "when not passed a block" do
|
305
|
-
it "returns nil" do
|
306
|
-
double_definition_create.call(:foobar)
|
307
|
-
subject.foobar.should be_nil
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
context "when passed a block" do
|
312
|
-
describe "#subject.method_name being called" do
|
313
|
-
it "returns the return value of the block" do
|
314
|
-
double_definition_create.call(:foobar) {:baz}
|
315
|
-
subject.foobar.should == :baz
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
context "when not passed args" do
|
321
|
-
describe "#subject.method_name being called with any arguments" do
|
322
|
-
it "invokes the implementation of the Stub" do
|
323
|
-
double_definition_create.call(:foobar) {:baz}
|
324
|
-
subject.foobar(1, 2).should == :baz
|
325
|
-
subject.foobar().should == :baz
|
326
|
-
subject.foobar([]).should == :baz
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
context "when passed args" do
|
332
|
-
describe "#subject.method_name being called with the passed-in arguments" do
|
333
|
-
it "invokes the implementation of the Stub" do
|
334
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
335
|
-
subject.foobar(1, 2).should == :baz
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
describe "#subject.method_name being called with different arguments" do
|
340
|
-
it "raises a DoubleNotFoundError" do
|
341
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
342
|
-
lambda do
|
343
|
-
subject.foobar
|
344
|
-
end.should raise_error(RR::Errors::DoubleNotFoundError)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
context "when #implementation_strategy is a Proxy" do
|
351
|
-
before do
|
352
|
-
def subject.foobar(*args)
|
353
|
-
:original_return_value
|
354
|
-
end
|
355
|
-
double_definition_create.stub
|
356
|
-
double_definition_create.proxy(subject)
|
357
|
-
end
|
358
|
-
|
359
|
-
context "when not passed a block" do
|
360
|
-
describe "#subject.method_name being called" do
|
361
|
-
it "invokes the original implementanion" do
|
362
|
-
double_definition_create.call(:foobar)
|
363
|
-
subject.foobar.should == :original_return_value
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
context "when passed a block" do
|
369
|
-
describe "#subject.method_name being called" do
|
370
|
-
it "invokes the original implementanion and invokes the block with the return value of the original implementanion" do
|
371
|
-
passed_in_value = nil
|
372
|
-
double_definition_create.call(:foobar) do |original_return_value|
|
373
|
-
passed_in_value = original_return_value
|
374
|
-
end
|
375
|
-
subject.foobar
|
376
|
-
passed_in_value.should == :original_return_value
|
377
|
-
end
|
378
|
-
|
379
|
-
it "returns the return value of the block" do
|
380
|
-
double_definition_create.call(:foobar) do |original_return_value|
|
381
|
-
:new_return_value
|
382
|
-
end
|
383
|
-
subject.foobar.should == :new_return_value
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
context "when passed args" do
|
389
|
-
describe "#subject.method_name being called with the passed-in arguments" do
|
390
|
-
it "invokes the implementation of the Stub" do
|
391
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
392
|
-
subject.foobar(1, 2).should == :baz
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
describe "#subject.method_name being called with different arguments" do
|
397
|
-
it "raises a DoubleNotFoundError" do
|
398
|
-
double_definition_create.call(:foobar, 1, 2) {:baz}
|
399
|
-
lambda do
|
400
|
-
subject.foobar
|
401
|
-
end.should raise_error(RR::Errors::DoubleNotFoundError)
|
402
|
-
end
|
403
|
-
end
|
404
|
-
end
|
405
|
-
end
|
406
|
-
end
|
407
|
-
|
408
|
-
context "when #verification_strategy is a DontAllow" do
|
409
|
-
before do
|
410
|
-
double_definition_create.dont_allow(subject)
|
411
|
-
end
|
412
|
-
|
413
|
-
context "when not passed args" do
|
414
|
-
describe "#subject.method_name being called with any arguments" do
|
415
|
-
it "raises a TimesCalledError" do
|
416
|
-
double_definition_create.call(:foobar)
|
417
|
-
lambda {subject.foobar}.should raise_error(RR::Errors::TimesCalledError)
|
418
|
-
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
419
|
-
end
|
420
|
-
end
|
421
|
-
end
|
422
|
-
|
423
|
-
context "when passed args" do
|
424
|
-
describe "#subject.method_name being called with the passed-in arguments" do
|
425
|
-
it "raises a TimesCalledError" do
|
426
|
-
double_definition_create.call(:foobar, 1, 2)
|
427
|
-
lambda {subject.foobar(1, 2)}.should raise_error(RR::Errors::TimesCalledError)
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
describe "#subject.method_name being called with different arguments" do
|
432
|
-
it "raises a DoubleNotFoundError" do
|
433
|
-
double_definition_create.call(:foobar, 1, 2)
|
434
|
-
lambda {subject.foobar()}.should raise_error(RR::Errors::DoubleNotFoundError)
|
435
|
-
end
|
436
|
-
end
|
437
|
-
end
|
438
|
-
end
|
439
|
-
end
|
440
|
-
end
|
441
|
-
end
|
442
|
-
end
|
443
|
-
end
|
@@ -1,546 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Injections
|
5
|
-
describe DoubleInjection do
|
6
|
-
attr_reader :subject, :method_name, :double_injection
|
7
|
-
macro("sets up subject and method_name") do
|
8
|
-
it "sets up subject and method_name" do
|
9
|
-
double_injection.subject.should === subject
|
10
|
-
double_injection.method_name.should == method_name.to_sym
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
before do
|
15
|
-
@subject = Object.new
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "mock/stub" do
|
19
|
-
context "when the subject responds to the injected method" do
|
20
|
-
before do
|
21
|
-
class << subject
|
22
|
-
attr_reader :original_foobar_called
|
23
|
-
|
24
|
-
def foobar
|
25
|
-
@original_foobar_called = true
|
26
|
-
:original_foobar
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
subject.should respond_to(:foobar)
|
31
|
-
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
32
|
-
stub(subject).foobar {:new_foobar}
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "being bound" do
|
36
|
-
it "sets __rr__original_{method_name} to the original method" do
|
37
|
-
subject.__rr__original_foobar.should == :original_foobar
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "being called" do
|
41
|
-
it "returns the return value of the block" do
|
42
|
-
subject.foobar.should == :new_foobar
|
43
|
-
end
|
44
|
-
|
45
|
-
it "does not call the original method" do
|
46
|
-
subject.foobar
|
47
|
-
subject.original_foobar_called.should be_nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "being reset" do
|
52
|
-
before do
|
53
|
-
RR::Space.reset_double(subject, :foobar)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "rebinds the original method" do
|
57
|
-
subject.foobar.should == :original_foobar
|
58
|
-
end
|
59
|
-
|
60
|
-
it "removes __rr__original_{method_name}" do
|
61
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "when the subject does not respond to the injected method" do
|
68
|
-
before do
|
69
|
-
subject.should_not respond_to(:foobar)
|
70
|
-
subject.methods.should_not include('foobar')
|
71
|
-
stub(subject).foobar {:new_foobar}
|
72
|
-
end
|
73
|
-
|
74
|
-
it "does not set __rr__original_{method_name} to the original method" do
|
75
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "being called" do
|
79
|
-
it "calls the newly defined method" do
|
80
|
-
subject.foobar.should == :new_foobar
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe "being reset" do
|
85
|
-
before do
|
86
|
-
RR::Space.reset_double(subject, :foobar)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "unsets the foobar method" do
|
90
|
-
subject.should_not respond_to(:foobar)
|
91
|
-
subject.methods.should_not include('foobar')
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "when the subject redefines respond_to?" do
|
97
|
-
it "does not try to call the implementation" do
|
98
|
-
class << subject
|
99
|
-
def respond_to?(method_symbol, include_private = false)
|
100
|
-
method_symbol == :foobar
|
101
|
-
end
|
102
|
-
end
|
103
|
-
mock(@subject).foobar
|
104
|
-
@subject.foobar.should == nil
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "mock/stub + proxy" do
|
110
|
-
context "when the subject responds to the injected method" do
|
111
|
-
context "when the subject has the method defined" do
|
112
|
-
describe "being bound" do
|
113
|
-
before do
|
114
|
-
def subject.foobar
|
115
|
-
:original_foobar
|
116
|
-
end
|
117
|
-
|
118
|
-
subject.should respond_to(:foobar)
|
119
|
-
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
120
|
-
stub.proxy(subject).foobar {:new_foobar}
|
121
|
-
end
|
122
|
-
|
123
|
-
it "aliases the original method to __rr__original_{method_name}" do
|
124
|
-
subject.__rr__original_foobar.should == :original_foobar
|
125
|
-
end
|
126
|
-
|
127
|
-
it "replaces the original method with the new method" do
|
128
|
-
subject.foobar.should == :new_foobar
|
129
|
-
end
|
130
|
-
|
131
|
-
describe "being called" do
|
132
|
-
it "calls the original method first and sends it into the block" do
|
133
|
-
original_return_value = nil
|
134
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
135
|
-
subject.foobar.should == :new_foobar
|
136
|
-
original_return_value.should == :original_foobar
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "being reset" do
|
141
|
-
before do
|
142
|
-
RR::Space.reset_double(subject, :foobar)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "rebinds the original method" do
|
146
|
-
subject.foobar.should == :original_foobar
|
147
|
-
end
|
148
|
-
|
149
|
-
it "removes __rr__original_{method_name}" do
|
150
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context "when the subject does not have the method defined" do
|
157
|
-
describe "being bound" do
|
158
|
-
context "when the subject has not been previously bound to" do
|
159
|
-
before do
|
160
|
-
setup_subject
|
161
|
-
|
162
|
-
subject.should respond_to(:foobar)
|
163
|
-
stub.proxy(subject).foobar {:new_foobar}
|
164
|
-
end
|
165
|
-
|
166
|
-
def setup_subject
|
167
|
-
def subject.respond_to?(method_name)
|
168
|
-
if method_name.to_sym == :foobar
|
169
|
-
true
|
170
|
-
else
|
171
|
-
super
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
it "does not define __rr__original_{method_name}" do
|
177
|
-
subject.methods.should_not include("__rr__original_foobar")
|
178
|
-
end
|
179
|
-
|
180
|
-
context "when method is defined after being bound and before being called" do
|
181
|
-
def setup_subject
|
182
|
-
super
|
183
|
-
def subject.foobar
|
184
|
-
:original_foobar
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe "being called" do
|
189
|
-
it "defines __rr__original_{method_name} to be the lazily created method" do
|
190
|
-
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
191
|
-
subject.__rr__original_foobar.should == :original_foobar
|
192
|
-
end
|
193
|
-
|
194
|
-
it "calls the original method first and sends it into the block" do
|
195
|
-
original_return_value = nil
|
196
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
197
|
-
subject.foobar.should == :new_foobar
|
198
|
-
original_return_value.should == :original_foobar
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
describe "being reset" do
|
203
|
-
before do
|
204
|
-
RR::Space.reset_double(subject, :foobar)
|
205
|
-
end
|
206
|
-
|
207
|
-
it "rebinds the original method" do
|
208
|
-
subject.foobar.should == :original_foobar
|
209
|
-
end
|
210
|
-
|
211
|
-
it "removes __rr__original_{method_name}" do
|
212
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
context "when method is still not defined" do
|
218
|
-
context "when the method is lazily created" do
|
219
|
-
def setup_subject
|
220
|
-
super
|
221
|
-
def subject.method_missing(method_name, *args, &block)
|
222
|
-
if method_name.to_sym == :foobar
|
223
|
-
def self.foobar
|
224
|
-
:original_foobar
|
225
|
-
end
|
226
|
-
|
227
|
-
foobar
|
228
|
-
else
|
229
|
-
super
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe "being called" do
|
235
|
-
it "defines __rr__original_{method_name} to be the lazily created method" do
|
236
|
-
subject.foobar
|
237
|
-
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
238
|
-
subject.__rr__original_foobar.should == :original_foobar
|
239
|
-
end
|
240
|
-
|
241
|
-
it "calls the lazily created method and returns the injected method return value" do
|
242
|
-
original_return_value = nil
|
243
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
244
|
-
subject.foobar.should == :new_foobar
|
245
|
-
original_return_value.should == :original_foobar
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
describe "being reset" do
|
250
|
-
context "when reset before being called" do
|
251
|
-
before do
|
252
|
-
RR::Space.reset_double(subject, :foobar)
|
253
|
-
end
|
254
|
-
|
255
|
-
it "rebinds the original method" do
|
256
|
-
subject.foobar.should == :original_foobar
|
257
|
-
end
|
258
|
-
|
259
|
-
it "removes __rr__original_{method_name}" do
|
260
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
context "when the method is not lazily created (handled in method_missing)" do
|
267
|
-
def setup_subject
|
268
|
-
super
|
269
|
-
def subject.method_missing(method_name, *args, &block)
|
270
|
-
if method_name.to_sym == :foobar
|
271
|
-
:original_foobar
|
272
|
-
else
|
273
|
-
super
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe "being called" do
|
279
|
-
it "does not define the __rr__original_{method_name}" do
|
280
|
-
subject.foobar
|
281
|
-
subject.methods.should_not include("__rr__original_foobar")
|
282
|
-
end
|
283
|
-
|
284
|
-
it "calls the lazily created method and returns the injected method return value" do
|
285
|
-
original_return_value = nil
|
286
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
287
|
-
subject.foobar.should == :new_foobar
|
288
|
-
original_return_value.should == :original_foobar
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
describe "being reset" do
|
293
|
-
before do
|
294
|
-
RR::Space.reset_double(subject, :foobar)
|
295
|
-
end
|
296
|
-
|
297
|
-
it "rebinds the original method" do
|
298
|
-
subject.foobar.should == :original_foobar
|
299
|
-
end
|
300
|
-
|
301
|
-
it "removes __rr__original_{method_name}" do
|
302
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
context "when the subject has been previously bound to" do
|
310
|
-
before do
|
311
|
-
setup_subject
|
312
|
-
|
313
|
-
subject.should respond_to(:foobar)
|
314
|
-
stub.proxy(subject).baz {:new_baz}
|
315
|
-
stub.proxy(subject).foobar {:new_foobar}
|
316
|
-
end
|
317
|
-
|
318
|
-
def setup_subject
|
319
|
-
def subject.respond_to?(method_name)
|
320
|
-
if method_name.to_sym == :foobar || method_name.to_sym == :baz
|
321
|
-
true
|
322
|
-
else
|
323
|
-
super
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
it "does not define __rr__original_{method_name}" do
|
329
|
-
subject.methods.should_not include("__rr__original_foobar")
|
330
|
-
end
|
331
|
-
|
332
|
-
context "when method is defined after being bound and before being called" do
|
333
|
-
def setup_subject
|
334
|
-
super
|
335
|
-
def subject.foobar
|
336
|
-
:original_foobar
|
337
|
-
end
|
338
|
-
end
|
339
|
-
|
340
|
-
describe "being called" do
|
341
|
-
it "defines __rr__original_{method_name} to be the lazily created method" do
|
342
|
-
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
343
|
-
subject.__rr__original_foobar.should == :original_foobar
|
344
|
-
end
|
345
|
-
|
346
|
-
it "calls the original method first and sends it into the block" do
|
347
|
-
original_return_value = nil
|
348
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
349
|
-
subject.foobar.should == :new_foobar
|
350
|
-
original_return_value.should == :original_foobar
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
describe "being reset" do
|
355
|
-
before do
|
356
|
-
RR::Space.reset_double(subject, :foobar)
|
357
|
-
end
|
358
|
-
|
359
|
-
it "rebinds the original method" do
|
360
|
-
subject.foobar.should == :original_foobar
|
361
|
-
end
|
362
|
-
|
363
|
-
it "removes __rr__original_{method_name}" do
|
364
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
365
|
-
end
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
context "when method is still not defined" do
|
370
|
-
context "when the method is lazily created" do
|
371
|
-
def setup_subject
|
372
|
-
super
|
373
|
-
def subject.method_missing(method_name, *args, &block)
|
374
|
-
if method_name.to_sym == :foobar
|
375
|
-
def self.foobar
|
376
|
-
:original_foobar
|
377
|
-
end
|
378
|
-
|
379
|
-
foobar
|
380
|
-
else
|
381
|
-
super
|
382
|
-
end
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
describe "being called" do
|
387
|
-
it "defines __rr__original_{method_name} to be the lazily created method" do
|
388
|
-
subject.foobar
|
389
|
-
(!!subject.methods.detect {|method| method.to_sym == :__rr__original_foobar}).should be_true
|
390
|
-
subject.__rr__original_foobar.should == :original_foobar
|
391
|
-
end
|
392
|
-
|
393
|
-
it "calls the lazily created method and returns the injected method return value" do
|
394
|
-
original_return_value = nil
|
395
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
396
|
-
subject.foobar.should == :new_foobar
|
397
|
-
original_return_value.should == :original_foobar
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
describe "being reset" do
|
402
|
-
context "when reset before being called" do
|
403
|
-
before do
|
404
|
-
RR::Space.reset_double(subject, :foobar)
|
405
|
-
end
|
406
|
-
|
407
|
-
it "rebinds the original method" do
|
408
|
-
subject.foobar.should == :original_foobar
|
409
|
-
end
|
410
|
-
|
411
|
-
it "removes __rr__original_{method_name}" do
|
412
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
413
|
-
end
|
414
|
-
end
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
context "when the method is not lazily created (handled in method_missing)" do
|
419
|
-
def setup_subject
|
420
|
-
super
|
421
|
-
def subject.method_missing(method_name, *args, &block)
|
422
|
-
if method_name.to_sym == :foobar
|
423
|
-
:original_foobar
|
424
|
-
else
|
425
|
-
super
|
426
|
-
end
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
describe "being called" do
|
431
|
-
it "does not define the __rr__original_{method_name}" do
|
432
|
-
subject.foobar
|
433
|
-
subject.methods.should_not include("__rr__original_foobar")
|
434
|
-
end
|
435
|
-
|
436
|
-
it "calls the lazily created method and returns the injected method return value" do
|
437
|
-
original_return_value = nil
|
438
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
439
|
-
subject.foobar.should == :new_foobar
|
440
|
-
original_return_value.should == :original_foobar
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
|
-
describe "being reset" do
|
445
|
-
before do
|
446
|
-
RR::Space.reset_double(subject, :foobar)
|
447
|
-
end
|
448
|
-
|
449
|
-
it "rebinds the original method" do
|
450
|
-
subject.foobar.should == :original_foobar
|
451
|
-
end
|
452
|
-
|
453
|
-
it "removes __rr__original_{method_name}" do
|
454
|
-
subject.should_not respond_to(:__rr__original_foobar)
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
459
|
-
end
|
460
|
-
end
|
461
|
-
end
|
462
|
-
end
|
463
|
-
|
464
|
-
context "when the subject does not respond to the injected method" do
|
465
|
-
context "when the subject responds to the method via method_missing" do
|
466
|
-
describe "being bound" do
|
467
|
-
before do
|
468
|
-
subject.should_not respond_to(:foobar)
|
469
|
-
subject.methods.should_not include('foobar')
|
470
|
-
class << subject
|
471
|
-
def method_missing(method_name, *args, &block)
|
472
|
-
if method_name == :foobar
|
473
|
-
:original_foobar
|
474
|
-
else
|
475
|
-
super
|
476
|
-
end
|
477
|
-
end
|
478
|
-
end
|
479
|
-
stub.proxy(subject).foobar {:new_foobar}
|
480
|
-
end
|
481
|
-
|
482
|
-
it "adds the method to the subject" do
|
483
|
-
subject.should respond_to(:foobar)
|
484
|
-
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
485
|
-
end
|
486
|
-
|
487
|
-
describe "being called" do
|
488
|
-
it "calls the original method first and sends it into the block" do
|
489
|
-
original_return_value = nil
|
490
|
-
stub.proxy(subject).foobar {|arg| original_return_value = arg; :new_foobar}
|
491
|
-
subject.foobar.should == :new_foobar
|
492
|
-
original_return_value.should == :original_foobar
|
493
|
-
end
|
494
|
-
end
|
495
|
-
|
496
|
-
describe "being reset" do
|
497
|
-
before do
|
498
|
-
RR::Space.reset_double(subject, :foobar)
|
499
|
-
end
|
500
|
-
|
501
|
-
it "unsets the foobar method" do
|
502
|
-
subject.should_not respond_to(:foobar)
|
503
|
-
subject.methods.should_not include('foobar')
|
504
|
-
end
|
505
|
-
end
|
506
|
-
end
|
507
|
-
end
|
508
|
-
|
509
|
-
context "when the subject would raise a NoMethodError when the method is called" do
|
510
|
-
describe "being bound" do
|
511
|
-
before do
|
512
|
-
subject.should_not respond_to(:foobar)
|
513
|
-
subject.methods.should_not include('foobar')
|
514
|
-
stub.proxy(subject).foobar {:new_foobar}
|
515
|
-
end
|
516
|
-
|
517
|
-
it "adds the method to the subject" do
|
518
|
-
subject.should respond_to(:foobar)
|
519
|
-
(!!subject.methods.detect {|method| method.to_sym == :foobar}).should be_true
|
520
|
-
end
|
521
|
-
|
522
|
-
describe "being called" do
|
523
|
-
it "raises a NoMethodError" do
|
524
|
-
lambda do
|
525
|
-
subject.foobar
|
526
|
-
end.should raise_error(NoMethodError)
|
527
|
-
end
|
528
|
-
end
|
529
|
-
|
530
|
-
describe "being reset" do
|
531
|
-
before do
|
532
|
-
RR::Space.reset_double(subject, :foobar)
|
533
|
-
end
|
534
|
-
|
535
|
-
it "unsets the foobar method" do
|
536
|
-
subject.should_not respond_to(:foobar)
|
537
|
-
subject.methods.should_not include('foobar')
|
538
|
-
end
|
539
|
-
end
|
540
|
-
end
|
541
|
-
end
|
542
|
-
end
|
543
|
-
end
|
544
|
-
end
|
545
|
-
end
|
546
|
-
end
|