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

Commit 06f7331

Browse files
askreetJonRowe
andauthored
Apply suggestions from code review
Co-authored-by: Jon Rowe <[email protected]>
1 parent 1f9d1b5 commit 06f7331

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/rspec/mocks/message_expectation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def and_return(first_value, *values)
9595
#
9696
# @return [nil] No further chaining is supported after this.
9797
# @example
98-
# allow(api).to receive(:get_foo).and_return(-> { raise ApiTimeout })
98+
# allow(api).to receive(:get_foo).and_invoke(-> { raise ApiTimeout })
9999
# api.get_foo # => raises ApiTimeout
100100
# api.get_foo # => raises ApiTimeout
101101
#
102-
# allow(api).to receive(:get_foo).and_return(-> { raise ApiTimeout }, -> { raise ApiTimeout }, -> { :a_foo })
102+
# allow(api).to receive(:get_foo).and_invoke(-> { raise ApiTimeout }, -> { raise ApiTimeout }, -> { :a_foo })
103103
# api.get_foo # => raises ApiTimeout
104104
# api.get_foo # => rasies ApiTimeout
105105
# api.get_foo # => :a_foo

spec/rspec/mocks/and_invoke_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Mocks
1313

1414
context 'when no argument is passed' do
1515
it 'raises ArgumentError' do
16-
expect { allow(obj).to receive(:foo).and_return }.to raise_error(ArgumentError)
16+
expect { allow(obj).to receive(:foo).and_invoke }.to raise_error(ArgumentError)
1717
end
1818
end
1919
end

0 commit comments

Comments
 (0)