[rspec-users] mocking errors
rupespad1 at mac.com
Sun Jun 24 10:28:24 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")
> Just wanted to check the best practice on this kind of thing and how
> other people handle it.
Don't know if this is the best way, but I do this sort of thing....
thing = Thing.create(:a_required_attribute => nil)
I don't think you need to mock the error handling code itself, you
just want to check that the result of passing an invalid attribute to
a model results in an error on that attribute.
Hope this makes sense
More information about the rspec-users