class ShowExceptions::ShowExceptionsFormatsTest

Public Instance Methods

test_render_fallback_exception() click to toggle source
# File actionpack/test/controller/show_exceptions_test.rb, line 91
def test_render_fallback_exception
  @app = ShowExceptionsOverriddenController.action(:boom)
  get "/", headers: { "HTTP_ACCEPT" => "text/csv" }
  assert_response :internal_server_error
  assert_equal "text/html", response.content_type.to_s
end
test_render_json_exception() click to toggle source
# File actionpack/test/controller/show_exceptions_test.rb, line 75
def test_render_json_exception
  @app = ShowExceptionsOverriddenController.action(:boom)
  get "/", headers: { "HTTP_ACCEPT" => "application/json" }
  assert_response :internal_server_error
  assert_equal "application/json", response.content_type.to_s
  assert_equal({ status: 500, error: "Internal Server Error" }.to_json, response.body)
end
test_render_xml_exception() click to toggle source
# File actionpack/test/controller/show_exceptions_test.rb, line 83
def test_render_xml_exception
  @app = ShowExceptionsOverriddenController.action(:boom)
  get "/", headers: { "HTTP_ACCEPT" => "application/xml" }
  assert_response :internal_server_error
  assert_equal "application/xml", response.content_type.to_s
  assert_equal({ status: 500, error: "Internal Server Error" }.to_xml, response.body)
end