Sha256: eb2115382ad9f7ac5c0a41743691079ed834e8b682ddd4caa4cc8531df1b15ee

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
module Rambulance #:nodoc:
  module TestHelper
    # 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
    #
    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rambulance-3.0.0 lib/rambulance/test_helper.rb
rambulance-2.3.0 lib/rambulance/test_helper.rb
rambulance-2.2.0 lib/rambulance/test_helper.rb
rambulance-2.0.0 lib/rambulance/test_helper.rb
rambulance-1.1.1 lib/rambulance/test_helper.rb
rambulance-1.1.0 lib/rambulance/test_helper.rb
rambulance-1.0.3 lib/rambulance/test_helper.rb
rambulance-1.0.2 lib/rambulance/test_helper.rb
rambulance-1.0.1 lib/rambulance/test_helper.rb
rambulance-1.0.0 lib/rambulance/test_helper.rb
rambulance-0.6.0 lib/rambulance/test_helper.rb