[rspec-users] mocking errors

David Smalley david.smalley.lists at googlemail.com
Sun Jun 24 09:22:00 EDT 2007


What is the correct way to mock out the errors on a Rails model?

I'm assuming i need to say

@mock_thing = mock_model(Thing)
@mock_thing_errors = mock("errors")
@mock_thing_errors.should_receive(:full_messages).and_return("An error")
@mock_thing.should_receive(:errors).and_return(@mock_thing_errors)

Just wanted to check the best practice on this kind of thing and how  
other people handle it.

Cheers,

David


More information about the rspec-users mailing list