From 5973e20fb0552d8a8291bdace15c625a94895bc7 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jul 2024 09:30:48 -0400 Subject: [PATCH] Add `have_http_header` rspec matcher --- spec/support/matchers/http_headers.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/support/matchers/http_headers.rb diff --git a/spec/support/matchers/http_headers.rb b/spec/support/matchers/http_headers.rb new file mode 100644 index 00000000000..6896037f33a --- /dev/null +++ b/spec/support/matchers/http_headers.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +RSpec::Matchers.define :have_http_header do |header, values| + match do |response| + response.headers[header].match?(values) + end + + failure_message do |response| + "Expected that `#{header}` would have values of `#{values}` but was `#{response.headers[header]}`" + end +end