Skip to content

Commit 327ef76

Browse files
authored
Merge pull request #31 from doudou/composite_expectation_robustness_v3
chore: compatibility with ActiveSupport's Object#with (v3+)
2 parents 5246f41 + 7070a50 commit 327ef76

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

lib/flexmock/composite_expectation.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ class FlexMock
33
# A composite expectation allows several expectations to be grouped into a
44
# single composite and then apply the same constraints to all expectations
55
# in the group.
6-
class CompositeExpectation
6+
class CompositeExpectation < BasicObject
7+
attr_reader :expectations
78

89
# Initialize the composite expectation.
910
def initialize

lib/flexmock/expectation_recorder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def method_missing(sym, *args, **kw, &block)
3434
def apply(mock)
3535
obj = mock
3636
@expectations.each do |sym, args, kw, block|
37-
obj = obj.send(sym, *args, **kw, &block)
37+
obj = obj.__send__(sym, *args, **kw, &block)
3838
end
3939
end
4040
end

test/should_receive_ruby21plus.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def test_with_signature_matching_sets_up_the_signature_predicate_based_on_the_pr
55
k = Class.new { def m(req_a:, req_b:, opt_c: 10, **kw_splat); end }
66
FlexMock.use do |mock|
77
e = mock.should_receive(:test).with_signature_matching(k.instance_method(:m))
8-
e = e.instance_variable_get(:@expectations).first
8+
e = e.expectations.first
99
validator = e.instance_variable_get(:@signature_validator)
1010
assert_equal 0, validator.required_arguments
1111
assert_equal 0, validator.optional_arguments

test/should_receive_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ def test_with_signature_matching_sets_up_the_signature_predicate_based_on_the_pr
14221422
k = Class.new { def m(req_a, req_b, opt_c = 10); end }
14231423
FlexMock.use do |mock|
14241424
e = mock.should_receive(:m).with_signature_matching(k.instance_method(:m))
1425-
e = e.instance_variable_get(:@expectations).first
1425+
e = e.expectations.first
14261426
validator = e.instance_variable_get(:@signature_validator)
14271427
assert_equal 2, validator.required_arguments
14281428
assert_equal 1, validator.optional_arguments
@@ -1437,7 +1437,7 @@ def test_with_signature_matching_sets_up_the_signature_predicate_based_on_the_pr
14371437
k = Class.new { def m(req_a, req_b, opt_c = 10, *splat); end }
14381438
FlexMock.use do |mock|
14391439
e = mock.should_receive(:m).with_signature_matching(k.instance_method(:m))
1440-
e = e.instance_variable_get(:@expectations).first
1440+
e = e.expectations.first
14411441
validator = e.instance_variable_get(:@signature_validator)
14421442
assert_equal 2, validator.required_arguments
14431443
assert_equal 1, validator.optional_arguments

0 commit comments

Comments
 (0)