[rspec-users] Stubbing errors for AR

Jerry West jerry.west at ntlworld.com
Sun Apr 29 05:15:44 EDT 2007

Look for mock_model (in the plugin examples???) and/or google for 
'making a mockery of ActiveRecord'.

Hope this helps,

s.ross wrote:
> 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,
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list