[rspec-devel] stubs

David Chelimsky dchelimsky at gmail.com
Mon Oct 2 09:01:52 EDT 2006


On 10/2/06, Luke Redpath <luke at agileevolved.com> wrote:
> I'm pretty sure that find() is defined in ActiveRecord::Base
> explicitly.

True.

> I never had any problems stubbing find() with Stubba.
>
> However, I was never able to stub the methods that are definately
> generated at run-time, such as find_by_* and related finders.
>
> Cheers
> Luke
>
> > I think it's a conflict w/ rails' usage of the Story metaclass. Here's
> > my theory (something akin to a wild ass guess) :new is defined on
> > Story when it is initially loaded, but :find is added by rails at
> > runtime, making a new metaclass. RSpec is telling Story to stub!
> > :find, but :find is not defined on Story, it's defined on a run-time
> > rails variation of Story.
> >
> > Any thoughts on this?

I found out something else of interest. On AR derivatives, this works:

    (class << Person; self; end).stub!(:create).with(false)

but this doesn't

    Person.stub!(:create).with(false)

Maybe that shed's some light? I'm still searching....

> >
> > David
> > _______________________________________________
> > rspec-devel mailing list
> > rspec-devel at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-devel
>
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the rspec-devel mailing list