Expect A Method To Be Called And Actually Call It
You can assert that a method is called without actually executing it. This is often what expect(...).to receive(:method_name)
is used for. If you do want that method called, RSpec can accommodate you.
Let's say we have the following two classes:
We can assert that say_hello
gets called without actually raising the exception (first it
block). If we tack on and_call_original
then RSpec will make the assertion and execute the method (second it
block).
Last updated