You may have a point when you’re writing specs that are meant to anticipate a 404 Not Found from a resource. You have a rescue like this:
..and now you need a test for it. In Rspec it’s not obvious, but easy. First, you need to stub your actions in your spec:
That sounds good, but it won’t work because it will fail with:
Arguments? I need to pass arguments to an error? I guess I do. Maybe the status code?
Ah ha! It needs some kind of object passed in to new()! But, what is it? We have no way of knowing off hand what object should be there. Wait, though, we’re INSIDE an environment that exists for making throw-away objects!
ActiveResource::ResourceNotFound.new(mock('err', :code => '404'))
Try that, you’ll get your exception!