Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit e90fa30

Browse files
askreetpirj
authored andcommitted
treat procs as if they were blocks to and_return
1 parent dea9067 commit e90fa30

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spec/rspec/mocks/and_invoke_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ module Mocks
4040
expect(dbl.square_then_cube(2)).to eq 8
4141
end
4242
end
43+
44+
context 'when calling passed callables' do
45+
let(:dbl) { double }
46+
47+
it 'passes the arguments into the callable' do
48+
expect(dbl).to receive(:square_then_cube).and_invoke(lambda { |i| i ** 2 },
49+
lambda { |i| i ** 3 })
50+
51+
expect(dbl.square_then_cube(2)).to eq 4
52+
expect(dbl.square_then_cube(2)).to eq 8
53+
end
54+
end
4355
end
4456
end
4557
end

0 commit comments

Comments
 (0)