[rspec-users] Rails 3.2.1 breaks stub ?
info at stupidtuesday.com
Mon Jan 30 07:45:41 EST 2012
You were right, and your fix worked like a charm!
Thanks for taking the time to reply. And thanks again for what you've
done and meant to the Rails community.
On Jan 29, 10:02 am, David Chelimsky <dchelim... at gmail.com> wrote:
> On Jan 29, 2012, at 7:53 AM, Larry wrote:
> > Hi David,
> > The trace is below.
> > Like I said, the line in the spec that causes the error (at least I
> > think it does; it works when I comment it out; plus, it fails in all 3
> > specs where I have a similar line) is:
> > act.stub(:update_attributes).and_raise(ActiveRecord::StaleObjectError)
> I didn't notice this before, but the first two lines of the backtrace reveal the problem.
> The `and_raise` method only works with an error class if that class has a 0-arg initializer . ActiveRecord::StaleObjectError's initializer requires two arguments . This changed between 3.1 and 3.2 [3,4].
> I added a placeholder for a feature request to improve the error messaging in rspec-mocks .
> To fix the problem (with or without helpful error messages from rspec), it's up to you to change
> to something like
> act.stub(:update_attributes).and_raise(ActiveRecord::StaleObjectError.new(act, :update))
More information about the rspec-users