[rspec-users] Stubbing errors for AR

s.ross cwdinfo at gmail.com
Sun Apr 29 03:52:24 EDT 2007


When mocking for an update method, I'm using this code.

     @mock_setting = mock("setting")
     Setting.should_receive(:find).once.and_return(@mock_setting)
     @mock_setting.stub!(:save).and_return(false)

All well and good, as it's supposed to generate a failed update.  
However, the

<%= error_messages_for 'setting' %>

wants a receiver for errors. Has anyone stubbed errors? The AR errors  
object has to respond to a bunch of stuff and I wanted to find out if  
someone had already done this (or if it's a dumb idea).

Thanks,


More information about the rspec-users mailing list