Skip to content

Instantly share code, notes, and snippets.

@yuki24
Created May 16, 2017 17:15
Show Gist options
  • Save yuki24/1081e85052b754fc0ad01fbccba46ede to your computer and use it in GitHub Desktop.
Save yuki24/1081e85052b754fc0ad01fbccba46ede to your computer and use it in GitHub Desktop.
def with_exceptions_app(enabled = true)
org_show_detailed_exceptions = Rails.application.env_config['action_dispatch.show_detailed_exceptions']
org_show_exceptions = Rails.application.env_config['action_dispatch.show_exceptions']
# This overrides the cached setting in Rails.application.config.consider_all_requests_local
Rails.application.env_config['action_dispatch.show_detailed_exceptions'] = !enabled
# Render templates instead of raising exceptions.
Rails.application.env_config['action_dispatch.show_exceptions'] = enabled
yield
ensure
Rails.application.env_config['action_dispatch.show_detailed_exceptions'] = org_show_detailed_exceptions
Rails.application.env_config['action_dispatch.show_exceptions'] = org_show_exceptions
end
it "shows an error page" do
with_exceptions_app do
get '/'
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment