Skip to content

Instantly share code, notes, and snippets.

@edgar
Created February 9, 2017 15:15
Show Gist options
  • Save edgar/fcac002d741ae2fb80be861f9ed05237 to your computer and use it in GitHub Desktop.
Save edgar/fcac002d741ae2fb80be861f9ed05237 to your computer and use it in GitHub Desktop.
require 'rails_helper'
RSpec.describe 'My API' do
let(:request) do
lambda do
get '/my_api/value-cannot-be-routed-due-to-route-constraints'
end
end
context 'when action_dispatch.show_exceptions is false (default behavior on test env)' do
it 'raise a routing error' do
expect { request.call }.to raise_error(ActionController::RoutingError)
end
end
context 'when action_dispatch.show_exceptions is true' do
before do
Rails.application.config.action_dispatch.show_exceptions = true
end
it 'return a 404' do
request.call
expect(response.status).to eq(404)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment