Created
February 13, 2020 17:35
-
-
Save MuhammetDilmac/32335e71e7fdec2b10f11b587075fe35 to your computer and use it in GitHub Desktop.
RSpec Have HTTP Header Matcher
This file contains 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
# 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