[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
gem.
See here for the documentation on the two rails mocking methods:
http://rspec.rubyforge.org/rspec-rails/1.1.11/classes/Spec/Rails/Mocks.html#M000026
There's also a good blog post on David's blog about stub_model
http://blog.davidchelimsky.net/2008/5/27/rspec-1-1-4
HTH,
Matt
More information about the rspec-users
mailing list