[rspec-users] and_return question
phillipkoebbe at gmail.com
Thu May 6 11:09:31 EDT 2010
Are these two forms theoretically functionally equivalent:
car = stub_model(Car)
I ask because I thought they were, but just hit something that suggests
they are not. I was originally using the first form, but then thought
I'd shorten it up a little (especially since nothing special is
happening in the stub_model call), so I changed it to form 2. But when I
did, I got an error:
NoMethodError in 'Web::Agent::NelliesController get :new should assign
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.id=
Line 140 of the spec was where I was using form 2. I change it back to
form 1 and the error went away.
More information about the rspec-users