[rspec-users] undefined method `mock_model' for [RSpec example]:#<Class:0x25550a8>

Zach Dennis zach.dennis at gmail.com
Mon Aug 20 21:55:58 EDT 2007

On 8/20/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> Several problems here:
> First, rspec_scaffold must be given a *singularised* name, in your
> case 'product'. (This is Rails being finicky, not RSpec).


> Second, after running rspec_scaffold you must run rake db:migrate

This I didn't do, but doing this makes no difference on the mock model
error. This does fix the issue if I run the spec from RAILS_ROOT, but
not if I run the spec from within the spec/views/products directory.

> Third, before you can run specs with ruby or spec, you must create the
> test database. This can be done with rake spec or rake db:test:prepare

The database was already in existence, so I left that part omitted in the video

If I run specs from RAILS_ROOT then everything works, but not if I'm
not in RAILS_ROOT. This is less of an issue I originally thought, but
the directory thing is a minor irritation, although I can make sure to
run specs from the RAILS_ROOT.



More information about the rspec-users mailing list