[rspec-users] (no subject)

David Chelimsky dchelimsky at gmail.com
Fri Feb 27 11:45:14 EST 2009

On Fri, Feb 27, 2009 at 10:14 AM, Marcus Roberts
<M.Roberts at nittygritty.net> wrote:
> Apologies as this feels like an FAQ, but the only answer I can find refers
> to a bug in a much earlier version of rspec, and this feels like a common
> thing to do, so I suspect we're doing something stupid.
> The issue seems to be that if we mock a class, that mock carries between
> specs when running 'rake spec' - the specs pass when run individually.
> In one spec, we mock an active record model:
> MachineInstance = mock("MachineInstance")

This is not an rspec bug :)

This is assigning the value mock("MachineInstance") to the constant
MachineInstance, which an interesting way to approach stubbing a
class, but not really the idea.

Can you show us the spec this is in so we can make appropriate recommendations?


> in a spec in another file that runs later, when we access MachineInstance as
> what should be a regular activerecord class, it's still a mock:
> Spec::Mocks::MockExpectationError in 'MachineInstance should create a new
> instance given valid attributes'
> Mock 'MachineInstance' received unexpected message :create! with
> ({:name=>"value for name", :machine_image_id=>1})
> We're running rspec 1.1.12.
> Thanks for any pointers.
> Marcus
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list