[rspec-users] respond_to? check in rspec-mocks

Justin Ko jko170 at gmail.com
Sat Aug 28 12:59:18 EDT 2010

> Not necessarily. In the case of a stub on a real object, the purpose is to control the environment in which the example runs. Consider a method on an object that returns one value before noon and a different value at noon and after. In an example for another object that depends on the time-dependent object, we might stub that method to respond as though it were before noon in one example, and after noon in another. This means that when you run this spec in the morning, the example that stubs morning-like behaviour is not changing anything or needing to fail. Same for the other example in the afternoon.
> Cheers,
> David

This is true, but the "morning" spec would fail in the afternoon (or/
and the afternoon spec would fail in the morning).

If the stub is not being touched, it should fail *at some point in

If the stub is not being touched, yet your specs are passing, then
technically there is nothing wrong with your app.

More information about the rspec-users mailing list