Created
May 16, 2017 17:15
-
-
Save yuki24/1081e85052b754fc0ad01fbccba46ede to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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