Skip to content

Instantly share code, notes, and snippets.

@MuhammetDilmac
Created February 13, 2020 17:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MuhammetDilmac/32335e71e7fdec2b10f11b587075fe35 to your computer and use it in GitHub Desktop.
Save MuhammetDilmac/32335e71e7fdec2b10f11b587075fe35 to your computer and use it in GitHub Desktop.
RSpec Have HTTP Header Matcher
# frozen_string_literal: true
require 'rspec/expectations'
# Example Usage; expect(response).to have_http_header('Auth-Token')
RSpec::Matchers.define :have_http_header do |expected_header|
match do |response|
response.headers.keys.include? expected_header
end
failure_message do
"expected #{expected_header} available on response headers but not exist"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment