Skip to content

Instantly share code, notes, and snippets.

@diraulo
Created February 27, 2020 10:46
Show Gist options
  • Save diraulo/e02d9a7a14c2c3e1f65cdb33e2770e52 to your computer and use it in GitHub Desktop.
Save diraulo/e02d9a7a14c2c3e1f65cdb33e2770e52 to your computer and use it in GitHub Desktop.
Sample GET request spec with custom headers
require 'rails_helper'
RSpec.describe Api::V1::ProductsController, type: :request do
describe 'GET#index' do
it 'list all products' do
# you can add more headers in that hash
headers = {
'ACCEPT' => 'application/json',
'CONTENT_TYPE' => 'application/json',
}
# Setup specs, create data
get '/api/v1/products', params: nil, headers: headers, as: :json
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment