On 8/8/07, Eivind Uggedal <
eivindu@...> wrote:
> Here you go:
http://pastie.caboo.se/85876OK - that helped.
The and_raise method can take an exception class or object. If you
pass it the class, it will try to create an instance of it using
Klass.new. This is the source of the problem. In your example we see:
@user.should_receive(:save!).and_raise(ActiveRecord::RecordInvalid)
Rspec tries to call ActiveRecord::RecordInvalid.new, but that requires
an argument, which is why you get an error saying it got 0 for 1
arguments.
Because and_raise can also take an exception object, the solution to
this problem is:
@user.should_receive(:save!).and_raise(ActiveRecord::RecordInvalid.new(@user))
I guess the root of the problem is poor docs - I'm updating the rdoc
now and it will be published with the next release.
Cheers,
David
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users