RSpec.configure do |config|
config.mock_with :rspec
config.run_all_when_everything_filtered = true
config.filter_run :focus
end it 'test1' do
test_obj = double
test_hash = { a: 3 }
expect(test_obj).to receive(:get).with(a_hash_including(test_hash)).and_return(5)
test_hash[:a] = 4
expect(test_obj).to receive(:get).with(a_hash_including(test_hash)).and_return(6)
expect(test_obj.get({ a: 3 })).to eq(5)
expect(test_obj.get({ a: 4 })).to eq(6)
end
it 'test2' do
test_obj = double
test_hash = { a: 3 }
expect(test_obj).to receive(:get).with(a_hash_including(test_hash)).and_return(5)
test_hash_dup = test_hash.dup
test_hash_dup[:a] = 4
expect(test_obj).to receive(:get).with(a_hash_including(test_hash_dup)).and_return(6)
expect(test_obj.get({ a: 3 })).to eq(5)
expect(test_obj.get({ a: 4 })).to eq(6)
end
Failure/Error: expect(test_obj.get({ a: 3 })).to eq(5)
#<Double (anonymous)> received :get with unexpected arguments
expected: (a hash including {:a => 4})
got: ({:a=>3})
Diff:
@@ -1,2 +1,2 @@
-["a hash including {:a => 4}"]
+[{:a=>3}]--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/8f87469c-d1ea-4735-9146-d4b1bd8a02f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.