Module: Rambulance::TestHelper

Defined in:
lib/rambulance/test_helper.rb

Instance Method Summary collapse

Instance Method Details

#with_exceptions_app(enabled: true) ⇒ Object

enables the exceptions app in the block.

Rspec:

it "shows an error page" do
  with_exceptions_app do
    get '/'
  end

  ...
end

Minitest:

test "it shows an error page" do
  with_exceptions_app do
    get '/'
  end

  ...
end


26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rambulance/test_helper.rb', line 26

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']

  Rails.application.env_config['action_dispatch.show_detailed_exceptions'] = !enabled
  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