[rspec-users] Unable to stub a class method in a before_filter

Matt Wynne matt at mattwynne.net
Tue Nov 4 15:56:55 EST 2008

On 4 Nov 2008, at 20:46, Fernando Perez wrote:

> Are the docs on mock outdated? I sometimes see mock_model, and  
> sometimes
> mock. Which one should be used?

For mock_model, you need to look at the rspec-rails gem, which is a  
separate library.

You actually have three choices when mocking an ActiveRecord model:  
mock, mock_model and stub_model. mock() belongs to rspec's core  
library, while the latter two come with the rails-specific extension  

See here for the documentation on the two rails mocking methods:

There's also a good blog post on David's blog about stub_model


More information about the rspec-users mailing list