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

David Chelimsky dchelimsky at gmail.com
Sun Aug 19 12:38:59 EDT 2007


On 8/19/07, Zach Dennis <zach.dennis at gmail.com> wrote:
> On 8/16/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > On 8/16/07, Zach Dennis <zach.dennis at gmail.com> wrote:
> > > On 8/16/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > > On 8/16/07, Zach Dennis <zach.dennis at gmail.com> wrote:
> > > > > I am getting:
> > > > >   undefined method `mock_model' for [RSpec example]:#<Class:0x25550a8>
> > > >
> > > > The fact that it says [RSpec example] means that it's not the right
> > > > class for a view spec. The plugin knows how to create the right class
> > > > based on one of two things:
> > > >
> > > > If the file is below /spec/views/
> > > >
> > > > or
> > > >
> > > > describe "...", :behaviour_type => :view do
> > > >   ...
> > > >
> > > > If the spec you're running satisfies either of these, you shouldn't be
> > > > seeing this.
> > > >
> > > > >
> > > > > with my view specs after upgrading to 1.0.8. Is anyone else seeing this?
> > > > >
> > > > > To isolate the message I did the following setup:
> > > > >
> > > > >  - create new rails project (with edge)
> > > > >  - installed rspec and rspec_on_rails
> > > > >  - ran rake spec
> > > > >  - ran script/generate rspec_scaffold products
> > > > >  - tried to run a builtin view spec
> > > >
> > > > When you say "builtin view spec," do you mean one that was generated
> > > > by running the rspec_scaffold generator?
> > > >
> > >
> > > One that was generated by the rspec_scaffold generator,
> >
> > Sorry man, it should be working fine. I'm not having that experience
> > personally - is anybody else?
> >
> > Zach - what platform are you on?
> >
>
> I tried on OSX and also Kubuntu Feisty. I think the rspec scaffold
> generators need to be updated to include  ", :behaviour_type =>
> :view".

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 sure I like those, but I kind of dislike :behaviour_type =>
:foo as a default.

WDYT?

David


>
> Zach
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list