flexmock 1.0.0.beta.3 → 1.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/flexmock/mock_container.rb +7 -2
- data/lib/flexmock/spy_describers.rb +2 -2
- data/lib/flexmock/version.rb +1 -1
- data/test/partial_mock_test.rb +9 -3
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -123,6 +123,7 @@ class FlexMock
|
|
123
123
|
safe_mode = false
|
124
124
|
model_class = nil
|
125
125
|
base_class = nil
|
126
|
+
mock = nil
|
126
127
|
while ! args.empty?
|
127
128
|
case args.first
|
128
129
|
when :base, :safe
|
@@ -139,6 +140,8 @@ class FlexMock
|
|
139
140
|
name = args.shift.to_s
|
140
141
|
when Hash
|
141
142
|
quick_defs = args.shift
|
143
|
+
when FlexMock
|
144
|
+
mock = args.shift
|
142
145
|
else
|
143
146
|
domain_obj = args.shift
|
144
147
|
end
|
@@ -150,9 +153,11 @@ class FlexMock
|
|
150
153
|
result = domain_obj
|
151
154
|
elsif model_class
|
152
155
|
id = ContainerHelper.next_id
|
153
|
-
|
156
|
+
mock ||= FlexMock.new("#{model_class}_#{id}", self)
|
157
|
+
result = mock
|
154
158
|
else
|
155
|
-
|
159
|
+
mock ||= FlexMock.new(name || "unknown", self)
|
160
|
+
result = mock
|
156
161
|
end
|
157
162
|
mock.should_receive(quick_defs)
|
158
163
|
yield(mock) if block_given?
|
@@ -20,8 +20,8 @@ class FlexMock
|
|
20
20
|
result << block_description(options[:with_block])
|
21
21
|
result << ".\n"
|
22
22
|
result << "The following messages have been received:\n"
|
23
|
-
spy.flexmock_calls.each do |
|
24
|
-
result << " " << call_description(
|
23
|
+
spy.flexmock_calls.each do |call_sym, call_args|
|
24
|
+
result << " " << call_description(call_sym, call_args) << "\n"
|
25
25
|
end
|
26
26
|
result
|
27
27
|
end
|
data/lib/flexmock/version.rb
CHANGED
data/test/partial_mock_test.rb
CHANGED
@@ -35,6 +35,12 @@ class TestStubbing < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_attempting_to_partially_mock_existing_mock_is_noop
|
39
|
+
m = flexmock("A")
|
40
|
+
flexmock(m)
|
41
|
+
assert ! m.instance_variables.include?(:@flexmock_proxy)
|
42
|
+
end
|
43
|
+
|
38
44
|
def test_stub_command_add_behavior_to_arbitrary_objects
|
39
45
|
obj = Object.new
|
40
46
|
flexmock(obj).should_receive(:hi).once.and_return(:stub_hi)
|
@@ -269,7 +275,7 @@ class TestStubbing < Test::Unit::TestCase
|
|
269
275
|
assert ! dog.respond_to?(sym), "should not have :#{sym} defined"
|
270
276
|
end
|
271
277
|
end
|
272
|
-
|
278
|
+
|
273
279
|
# This test ensures that singleton? does not use the old methods(false)
|
274
280
|
# call that has fallen out of favor in Ruby 1.9. In multiple 1.9 releases
|
275
281
|
# Delegator#methods will not even accept the optional argument, making flexmock
|
@@ -280,13 +286,13 @@ class TestStubbing < Test::Unit::TestCase
|
|
280
286
|
raise "Should not be called in the test lifecycle"
|
281
287
|
end
|
282
288
|
end
|
283
|
-
|
289
|
+
|
284
290
|
def test_object_methods_method_is_not_used_in_singleton_checks
|
285
291
|
obj = NoMethods.new
|
286
292
|
def obj.mock() :original end
|
287
293
|
assert_nothing_raised { flexmock(obj) }
|
288
294
|
end
|
289
|
-
|
295
|
+
|
290
296
|
def test_partial_mocks_with_mock_method_singleton_colision_have_original_defs_restored
|
291
297
|
dog = Dog.new
|
292
298
|
def dog.mock() :original end
|