From 783923d6879a2f9df9fee8ef24cecca6ac21136e Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Sat, 30 Dec 2017 23:35:27 -0800 Subject: [PATCH] Make spec less brittle. On Ruby 2.5, this spec failed, apparently due to the fact that Method equality has changed on 2.5 slightly. The method instances have always been different but 2.4 and before considered them equivalent. Instead, we can show that the two method objects _behave_ the same, which is what we really care about. Fixes #1192. --- spec/rspec/mocks/and_wrap_original_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/rspec/mocks/and_wrap_original_spec.rb b/spec/rspec/mocks/and_wrap_original_spec.rb index df9cae46..2d4d0a8b 100644 --- a/spec/rspec/mocks/and_wrap_original_spec.rb +++ b/spec/rspec/mocks/and_wrap_original_spec.rb @@ -26,12 +26,13 @@ def results }.to raise_error NameError end - it "passes in the original method" do - value = nil + it "passes along the original method" do + passed_method = nil original_method = instance.method(:results) - allow_it.to receive(:results).and_wrap_original { |m| value = m } + allow_it.to receive(:results).and_wrap_original { |m| passed_method = m } instance.results - expect(value).to eq original_method + + expect(passed_method.call).to eq(original_method.call) end it "passes along the message arguments" do