Created
March 24, 2018 01:23
-
-
Save marksiemers/da361eced265e2a2ff50138fa7746d97 to your computer and use it in GitHub Desktop.
Sample request spec for 404s in RSpec/Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'API Request', type: :request do | |
let!(:request) do | |
-> { rails_respond_without_detailed_exceptions { get '/bad/path' } } | |
end | |
context 'first context, perhaps when a user is signed in' do | |
before { request.call } | |
it 'returns http not found (404)' do | |
expect(response).to have_http_status(:not_found) | |
end | |
end | |
context "second context, perhaps when an admin user is signed in" do | |
before { request.call } | |
it 'returns http not found (404)' do | |
expect(response).to have_http_status(:not_found) | |
end | |
end | |
context "third context, perhaps when no one is signed in" do | |
before { request.call } | |
it 'returns http redirect (302)' do | |
expect(response).to have_http_status(302) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment