Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rspec-default_http_header

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rspec-default_http_header

  • 0.0.6
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

RSpec::DefaultHttpHeader

Set default http headers in request specs.

Installation

Add this line to your application's Gemfile:

gem 'rspec-default_http_header'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rspec-default_http_header

Setup

Include RSpec::DefaultHeader into your RSpec.configuration.

RSpec.configure do |config|
  config.include RSpec::DefaultHttpHeader, type: :request
end

Usage

let(:default_headers)

RSpec.describe 'GET /api/users.json' do
  context 'with authorization headers' do
    let(:default_headers) { {Authorization: 'your-authorization-token'} }

    before do
      get '/api/users.json'
    end

    it { expect(response).to be_success}
  end
end

modify default_headers hash

RSpec.describe 'GET /api/users.json' do
  context 'with authorization headers' do
    before do
      default_headers[:Authorization] = 'your-authorization-token'

      get '/api/users.json'
    end

    it { expect(response).to be_success}
  end
end

set in a batch to tests using the tag

RSpec.configure do |config|
  config.before(:example, type: :request, authorized: true) do
    default_headers[:Authorization] = 'your-authorization-token'
  end
end

RSpec.describe 'GET /api/users.json' do
  context 'with authorization headers', :authorized do
    before do
      get '/api/users.json'
    end

    it { expect(response).to be_success}
  end
end

Contributing

  1. Fork it ( https://github.com/kenchan/rspec-default_http_header/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

FAQs

Package last updated on 21 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc