flexmock 2.4.0 → 2.4.2
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 +4 -4
- data/flexmock.gemspec +1 -1
- data/lib/flexmock/core.rb +1 -1
- data/lib/flexmock/expectation.rb +10 -4
- data/lib/flexmock/partial_mock.rb +3 -10
- data/lib/flexmock/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55630790b40e21c94d842f9b5a173f0a3e2535aa40c4cc23c00aaaedaeaeb31a
|
4
|
+
data.tar.gz: 2afc06542cbe3ef561fb51239ccdfd646e677ee5508038d7532fe427049713f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e41731de6baa727d4580e5033180becda98c24a9b0522bf41a802f133023e20d6052c2d4a812ee435204cc8159bfdab32d3ddc66922ba8a69b8bf4427e89e13e
|
7
|
+
data.tar.gz: fc31b71f78372d05cc3e44e7648d9a5c8c9f7499ac56a4713e63eb1a3db4ba4f9b2107ae989cf967d44e0206e0f8e134ec675821c3710248952835daa8e1b457
|
data/flexmock.gemspec
CHANGED
data/lib/flexmock/core.rb
CHANGED
@@ -207,7 +207,7 @@ class FlexMock
|
|
207
207
|
|
208
208
|
# Invocke the original non-mocked functionality for the given
|
209
209
|
# symbol.
|
210
|
-
def flexmock_invoke_original(method_name, args)
|
210
|
+
def flexmock_invoke_original(method_name, args, orig_block)
|
211
211
|
return FlexMock.undefined
|
212
212
|
end
|
213
213
|
|
data/lib/flexmock/expectation.rb
CHANGED
@@ -128,7 +128,7 @@ class FlexMock
|
|
128
128
|
|
129
129
|
if @expected_block
|
130
130
|
ret_block.call(*args, &block)
|
131
|
-
elsif block
|
131
|
+
elsif block && @expected_block.nil?
|
132
132
|
ret_block.call(*args, block)
|
133
133
|
else
|
134
134
|
ret_block.call(*args)
|
@@ -405,16 +405,22 @@ class FlexMock
|
|
405
405
|
|
406
406
|
def pass_thru(&block)
|
407
407
|
block ||= lambda { |value| value }
|
408
|
-
and_return { |*args|
|
408
|
+
and_return { |*args, &orig_block|
|
409
409
|
begin
|
410
|
-
|
410
|
+
if @expected_block.nil? && !orig_block
|
411
|
+
if Proc === args.last
|
412
|
+
orig_block = args.last
|
413
|
+
args = args[0..-2]
|
414
|
+
end
|
415
|
+
end
|
416
|
+
block.call(@mock.flexmock_invoke_original(@sym, args, orig_block))
|
411
417
|
rescue NoMethodError => e
|
412
418
|
if e.name == @sym
|
413
419
|
raise e, "#{e.message} while performing #pass_thru in expectation object #{self}"
|
414
420
|
else
|
415
421
|
raise
|
416
422
|
end
|
417
|
-
end
|
423
|
+
end
|
418
424
|
}
|
419
425
|
end
|
420
426
|
|
@@ -162,10 +162,7 @@ class FlexMock
|
|
162
162
|
#
|
163
163
|
# Usually called in a #and_return statement
|
164
164
|
def invoke_original(m, *args, &block)
|
165
|
-
|
166
|
-
args << block
|
167
|
-
end
|
168
|
-
flexmock_invoke_original(m, args)
|
165
|
+
flexmock_invoke_original(m, args, block)
|
169
166
|
end
|
170
167
|
|
171
168
|
# Whether the given method's original definition has been stored
|
@@ -321,7 +318,7 @@ class FlexMock
|
|
321
318
|
# (3) Apply any recorded expecations
|
322
319
|
#
|
323
320
|
def create_new_mocked_object(allocate_method, args, recorder, block)
|
324
|
-
new_obj = flexmock_invoke_original(allocate_method, args)
|
321
|
+
new_obj = flexmock_invoke_original(allocate_method, args, nil)
|
325
322
|
mock = flexmock_container.flexmock(new_obj)
|
326
323
|
block.call(mock) unless block.nil?
|
327
324
|
recorder.apply(mock)
|
@@ -331,12 +328,8 @@ class FlexMock
|
|
331
328
|
|
332
329
|
# Invoke the original definition of method on the object supported by
|
333
330
|
# the stub.
|
334
|
-
def flexmock_invoke_original(method, args)
|
331
|
+
def flexmock_invoke_original(method, args, block)
|
335
332
|
if (original_method = find_original_method(method))
|
336
|
-
if Proc === args.last
|
337
|
-
block = args.last
|
338
|
-
args = args[0..-2]
|
339
|
-
end
|
340
333
|
original_method.call(*args, &block)
|
341
334
|
else
|
342
335
|
@obj.__send__(:method_missing, method, *args, &block)
|
data/lib/flexmock/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-09-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -165,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
165
|
requirements:
|
166
166
|
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version: '2.
|
168
|
+
version: '2.2'
|
169
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - ">="
|