On 26 Oct 2007, at 11:55, Tarsoly András wrote:
> So any pointers, help or links to some quick rundown regarding this
> problem would be greatly appreciated.
From a brief look over (apologies if I missed something), you are
not invoking the errors you need to cause your rescue etc blocks to run.
I think you want to do:
@foo.should_receive(:update_attributes!).with(params
[:foo]).and_raise(RecordNotSaved)
@object_in_rescue_block.should_receive(:some_message)
get :action, :id => 1
What you appear to be doing here:
> it "should retrieve a Foo instance, identified by ID and throw an
> exception, because of bad parameters" do
> Foo.should_receive(:find).with("1").and_return(@foo)
> lambda { @foo.should_receive(:update_attributes!).with
> (valid_params).and_return(@foo) }.should raise_error
> get :action, :id => 1
> end
is testing that the code throws an exception, NOT that your code
handles it; ie you are describing an assumption of someone else's
code rather than the behaviour of yours, which is not what you want
in a spec.
Ashley
--
blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ work
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users