On 13.9.2007, at 23.29, aslak hellesoy wrote:
On 9/13/07, Jarkko Laine <[EMAIL PROTECTED]> wrote:I've come across rather strange behaviour when trying to raise an exception in a stubbed method.I'm speccing the behaviour of a Rails create action, where I'm using save! to catch failed saves. In the case of working save, I'm using the following stub: @client.stub!(:save!).and_return(true) which works fine. However, in the negative case, @client.stub!(:save!).and_raise(ActiveRecord::RecordInvalid)Passing a class only works if the new method takes 0 args. Otherwise you have to pass an exception instance. ActiveRecord::RecordInvalid takes one.@client.stub!(:save!).and_raise(ActiveRecord::RecordInvalid.new (@client))
Cheers, that was it! //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users