No release in over 3 years
Low commit activity in last 3 years
Toggle showing of error pages on/off when testing
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
 Project Readme

ConfigurableExceptions

Test your 404/500 pages by toggling on/off showing of error pages on a per spec-basis.

Installation

Add this line to your application's Gemfile:

gem 'configurable_exceptions', group: :test

If you're using RSpec, dump something like this in spec/support/allow_rescue.rb:

RSpec.configure do |config|
  config.around(:example, :allow_rescue) do |example|
    ConfigurableExceptions.show_exceptions = true
    example.run
    ConfigurableExceptions.show_exceptions = false
  end
end

Usage

scenario 'Show 404 for non-existant posts', :allow_rescue do
  visit post_path(3)
  expect(page).to have_content('was not found')
end

Why?

After extensive stackoverflowing, couldn't find a good way of turning exception pages on for select specs only. Setting Rails.application.config.action_dispatch.show_exceptions in the RSpec configure block seems to only work for the first spec and then gets stuck, so although it works in isolation it's no good for running the whole suite. Thus, this configurable middleware that forces the ShowErrors middleware to show exceptions when activated.