[rspec-devel] stubs

Brian Takita brian.takita at gmail.com
Mon Oct 2 13:28:22 EDT 2006


>
> 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)
>

Interesting. I'll be able to look at this tonight.

On 10/2/06, David Chelimsky <dchelimsky at gmail.com> wrote:
>
> 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
> >
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20061002/5a65a38c/attachment.html 


More information about the rspec-devel mailing list