Skip to content

Commit

Permalink
treat procs as if they were blocks to and_return
Browse files Browse the repository at this point in the history
  • Loading branch information
askreet authored and JonRowe committed Nov 10, 2022
1 parent b234f4f commit 994e02d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/rspec/mocks/and_invoke_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ module Mocks
expect(dbl.square_then_cube(2)).to eq 8
end
end

context 'when calling passed callables' do
let(:dbl) { double }

it 'passes the arguments into the callable' do
expect(dbl).to receive(:square_then_cube).and_invoke(lambda { |i| i ** 2 },
lambda { |i| i ** 3 })

expect(dbl.square_then_cube(2)).to eq 4
expect(dbl.square_then_cube(2)).to eq 8
end
end
end
end
end

0 comments on commit 994e02d

Please sign in to comment.