Skip to content

Instantly share code, notes, and snippets.

@quadrolls
Created April 7, 2016 20:39
Show Gist options
  • Save quadrolls/9203f924f934398f6992162bbbcb1a0c to your computer and use it in GitHub Desktop.
Save quadrolls/9203f924f934398f6992162bbbcb1a0c to your computer and use it in GitHub Desktop.
Adding headers to a request in a controller spec in RSpec 3 and Rails 4
require 'rails_helper'
RSpec.describe Api::LoginsController, type: :controller do
before :each do
@header_code = 'AZSALE12345'
end
describe 'logout', focus: true do
it 'returns status 204' do
request.headers.merge!({'X-GROUP-CODE': @header_code})
post :logout
expect(response.status).to eq(204)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment