Method: RSpec::Mocks::ExampleMethods#have_received
- Defined in:
- lib/rspec/mocks/example_methods.rb
#have_received(method_name, &block) ⇒ Object
Note:
have_received(...).with(...)
is unable to work properly when
passed arguments are mutated after the spy records the received message.
Verifies that the given object received the expected message during the course of the test. On a spy objects or as null object doubles this works for any method, on other objects the method must have been stubbed beforehand in order for messages to be verified.
Stubbing and verifying messages received in this way implements the Test Spy pattern.
281 282 283 |
# File 'lib/rspec/mocks/example_methods.rb', line 281 def have_received(method_name, &block) Matchers::HaveReceived.new(method_name, &block) end |