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

aslak hellesoy aslak.hellesoy at gmail.com
Mon Aug 20 20:19:46 EDT 2007


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

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

HTH,
Aslak

On 8/21/07, Zach Dennis <zach.dennis at gmail.com> wrote:
> Here is a link to the .mov:
>
>   http://www.continuousthinking.com/movies/RSpec_mockModelError.mov
>
> In doing this I realized something. I only get the error when I try to
> run an individual spec within the spec/views/<model_name>/ directory.
> Thanks for the suggestion Jay,
>
> Zach
>
>
>
> On 8/20/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > On 8/20/07, Jay Levitt <lists-rspec at shopwatch.org> wrote:
> > > aslak hellesoy wrote:
> > > > On 8/20/07, Jay Levitt <lists-rspec at shopwatch.org> wrote:
> > > >>> I'd like to avoid that because it would be extra noise and it
> > > >>> shouldn't be necessary. The generated specs work absolutely perfectly
> > > >>> for me as/is (I'm on OS X). There have been a couple of bugs related
> > > >>> to regexps and windows paths over time, but they've either been
> > > >>> resolved or await more feedback from users in the tracker.
> > > >>>
> > > >>> I'm thinking about other ways to be explicit about this (besides the
> > > >>> verbose ":behaviour_type => :view". What if we added methods like:
> > > >>>
> > > >>> describe_model
> > > >>> describe_view
> > > >>> describe_controller
> > > >>> describe_helper
> > > >>>
> > > >>> Or support the first argument being a Symbol:
> > > >>>
> > > >>> describe :model, "Thing" do
> > > >> I'm not clear why we need any new syntax at all - isn't this just a bug
> > > >> related to some configurations, if it works for David but not for Zach
> > > >> (both on OS X)?
> > > >>
> > > >
> > > > Good point. Let's figure out why it doesn't work for Zach first.
> > > >
> > > > Zach: What's the relative path of the spec? Did you move it after it
> > > > was created?
> > >
> > > If Zach could create a screencast or precise step-by-step, I can attempt
> > > to reproduce it tonight on OS X, Windows XP, Cygwin, and/or Ubuntu 6.06.
> >
> > Thanks for offering to do this Jay - that's great.
> >
> > >
> > > Jay
> > >
> > >
> > > _______________________________________________
> > > rspec-users mailing list
> > > rspec-users at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/rspec-users
> > >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list