I’m trying to test how my screen handles an error return from an Ajax call. In
order to accomplish this, I need the Ajax call to return the error response,
and I’d like to do that by mocking the controller action. I’d like to do
something like:
allow_any_instance_of(BooksController).to receive(:modify) { render status:
:not_found, json: "Unknown book: #{@book.id}" }
But the render call gives an “undefined method” error, presumably because I’m
in a test and not in a controller method. Is there a way for me to mock this
behavior, or do I somehow have to manipulate the actual controller into the
desired behavior?
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/4E901F64-D8F3-45FA-B49B-25E67B7E3988%40pobox.com.