Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Correctly throwing exception if controller used is not the controller…

… that should have been tested
  • Loading branch information...
commit 4f2c4b391b580060a83c75bdf3b2e863d68493c4 1 parent e5bc712
Justin Knowlden gus authored
8 lib/riot/action_controller/http_methods.rb
View
@@ -11,7 +11,13 @@ def get(uri, params={}, &block)
http_reset
@env = ::Rack::MockRequest.env_for(uri, {:params => params})
@env['action_dispatch.show_exceptions'] = false
- @app.call(@env)
+ returning(@app.call(@env)) do |call_response|
+ c = @env["action_controller.instance"]
+ unless c.class.controller_name == topic.controller_name
+ msg = "Expected #{topic.controller_name} controller, not #{c.class.controller_name}"
+ raise ControllerMismatch, msg
+ end
+ end
end
def post; raise Exception, "POST isn't ready yet"; end
2  test/action_controller/get_request_test.rb
View
@@ -7,7 +7,7 @@
end.raises(AbstractController::ActionNotFound, "The action 'blah' could not be found")
asserts("controller does not match the one under test") do
- get "/gremlins/2"
+ get "/gremlins"
end.raises(RiotRails::ActionController::ControllerMismatch, "Expected rooms controller, not gremlins")
context "for a GET request" do
Please sign in to comment.
Something went wrong with that request. Please try again.