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