flexmock 1.0.0.beta.3 → 1.0.0.beta.4

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.
data/README.rdoc CHANGED
@@ -3,7 +3,7 @@
3
3
  FlexMock is a simple, but flexible, mock object library for Ruby unit
4
4
  testing.
5
5
 
6
- Version :: 1.0.0.beta.3
6
+ Version :: 1.0.0.beta.4
7
7
 
8
8
  = Links
9
9
 
@@ -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
- result = mock = FlexMock.new("#{model_class}_#{id}", self)
156
+ mock ||= FlexMock.new("#{model_class}_#{id}", self)
157
+ result = mock
154
158
  else
155
- result = mock = FlexMock.new(name || "unknown", self)
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 |sym, args|
24
- result << " " << call_description(sym, args) << "\n"
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
@@ -5,7 +5,7 @@ class FlexMock
5
5
  MINOR = 0,
6
6
  BUILD = 0,
7
7
  BETA = 'beta',
8
- BETAREV = 3,
8
+ BETAREV = 4,
9
9
  ]
10
10
  end
11
11
 
@@ -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
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: flexmock
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.0.0.beta.3
5
+ version: 1.0.0.beta.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jim Weirich