diff --git a/lib/flexmock/composite_expectation.rb b/lib/flexmock/composite_expectation.rb index 370046f..6ffbd42 100644 --- a/lib/flexmock/composite_expectation.rb +++ b/lib/flexmock/composite_expectation.rb @@ -3,7 +3,8 @@ class FlexMock # A composite expectation allows several expectations to be grouped into a # single composite and then apply the same constraints to all expectations # in the group. - class CompositeExpectation + class CompositeExpectation < BasicObject + attr_reader :expectations # Initialize the composite expectation. def initialize diff --git a/lib/flexmock/expectation_recorder.rb b/lib/flexmock/expectation_recorder.rb index f9624da..a21b7c4 100644 --- a/lib/flexmock/expectation_recorder.rb +++ b/lib/flexmock/expectation_recorder.rb @@ -34,7 +34,7 @@ def method_missing(sym, *args, &block) def apply(mock) obj = mock @expectations.each do |sym, args, block| - obj = obj.send(sym, *args, &block) + obj = obj.__send__(sym, *args, &block) end end end diff --git a/test/should_receive_ruby21plus.rb b/test/should_receive_ruby21plus.rb index cf00cdf..4e78acf 100644 --- a/test/should_receive_ruby21plus.rb +++ b/test/should_receive_ruby21plus.rb @@ -5,7 +5,7 @@ def test_with_signature_matching_sets_up_the_signature_predicate_based_on_the_pr k = Class.new { def m(req_a:, req_b:, opt_c: 10, **kw_splat); end } FlexMock.use do |mock| e = mock.should_receive(:test).with_signature_matching(k.instance_method(:m)) - e = e.instance_variable_get(:@expectations).first + e = e.expectations.first validator = e.instance_variable_get(:@signature_validator) assert_equal 0, validator.required_arguments assert_equal 0, validator.optional_arguments diff --git a/test/should_receive_test.rb b/test/should_receive_test.rb index 6710b12..f2ec04d 100644 --- a/test/should_receive_test.rb +++ b/test/should_receive_test.rb @@ -1530,7 +1530,7 @@ def test_with_signature_matching_sets_up_the_signature_predicate_based_on_the_pr k = Class.new { def m(req_a, req_b, opt_c = 10); end } FlexMock.use do |mock| e = mock.should_receive(:m).with_signature_matching(k.instance_method(:m)) - e = e.instance_variable_get(:@expectations).first + e = e.expectations.first validator = e.instance_variable_get(:@signature_validator) assert_equal 2, validator.required_arguments assert_equal 1, validator.optional_arguments @@ -1545,7 +1545,7 @@ def test_with_signature_matching_sets_up_the_signature_predicate_based_on_the_pr k = Class.new { def m(req_a, req_b, opt_c = 10, *splat); end } FlexMock.use do |mock| e = mock.should_receive(:m).with_signature_matching(k.instance_method(:m)) - e = e.instance_variable_get(:@expectations).first + e = e.expectations.first validator = e.instance_variable_get(:@signature_validator) assert_equal 2, validator.required_arguments assert_equal 1, validator.optional_arguments