In Rails 4, you can do this with
RSpec.configure do |config|
config.before(:each, allow_rescue: true) do
Rails.application.config.action_dispatch.stub(:show_exceptions) { true }
Rails.application.config.stub(:consider_all_requests_local) { false }
end
end
And then in the test file:
describe "A test" do
it "renders custom error pages", :allow_rescue => true do
end
end
The name :allow_rescueis taken from the configuration ActionController::Base.allow_rescuethat exists in Rails 3 , and there the RSpec configuration will be:
RSpec.configure do |config|
config.before(:each, allow_rescue: true) do
ActionController::Base.stub(:allow_rescue) { true }
end
end
source
share