[rspec-users] undefined method `mock_model' for [RSpec example]:#<Class:0x25550a8>
zach.dennis at gmail.com
Fri Aug 24 10:53:17 EDT 2007
On 8/20/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 8/20/07, Zach Dennis <zach.dennis at gmail.com> wrote:
> > 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).
> > ok
> > > 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.
> Ah - now THAT makes sense. This won't work on any system at all. RSpec
> looks for /spec/views/ in the path to know that it's a view spec. If
> you're in the view spec directory, it doesn't get the information it
> needs. Make sense?
> > > 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.
> We'd have to change how rspec figures out what behaviour_type to use
> to reduce the irritation. Any suggestions?
Use expand_path on the current file and see if it is in RAILS_ROOT/specs/views ?
More information about the rspec-users