Stubs, Mocks, Spies, and Fakes

Another option I use a lot is the spy method (introduced in RSpec 3.1) which means you don’t have to repeat what the name of the method you’re mocking:

clone = spy("clone")
expect(clone).to have_received(:solution)
1 Like