[rspec-devel] stubs

David Chelimsky dchelimsky at gmail.com
Mon Oct 2 06:58:39 EDT 2006


Hey Brian,

I'm trying to use the stubbing and partial_mocking. Check this out:

If I do this:

    Story.stub!(:new).with(@story)

all is well. But if I do this:

    Story.stub!(:find).with(@story)

I get a bunch of errors like this:

    singleton method called for a different object

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?

David


More information about the rspec-devel mailing list