Skip to content

Commit

Permalink
Merge fed03c9 into 19d39b7
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Jul 12, 2013
2 parents 19d39b7 + fed03c9 commit e0413ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rspec/mocks/example_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def hide_const(constant_name)
# # You can also use most message expectations:
# expect(invitation).to have_received(:accept).with(mailer).once
def have_received(method_name)
raise "have_received matcher does not take a block argument: #{caller[0]}" if block_given?
Matchers::HaveReceived.new(method_name)
end

Expand Down
8 changes: 8 additions & 0 deletions spec/rspec/mocks/matchers/have_received_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ module Mocks
}.to raise_error(/0 times/)
end

it "raises an exception when a block is used to match the arguments" do
dbl = double_with_met_expectation(:expected_method)
expect {
expect(dbl).to have_received(:expected_method) { |argument|
}
}.to raise_error(/have_received matcher does not take a block argument/)
end

context "with" do
it 'passes when the given args match the args used with the message' do
dbl = double_with_met_expectation(:expected_method, :expected, :args)
Expand Down

0 comments on commit e0413ea

Please sign in to comment.