Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support regex header matching via expect_header_matches
Browse files Browse the repository at this point in the history
rfletcher committed Nov 5, 2015
1 parent fedc467 commit a413dfe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/airborne/request_expectations.rb
Original file line number Diff line number Diff line change
@@ -44,6 +44,10 @@ def expect_header_contains(key, content)
expect_header_impl(key, content, true)
end

def expect_header_matches(key, content)
expect_header_impl(key, content, false, true)
end

def optional(hash)
OptionalHashTypeExpectations.new(hash)
end
@@ -58,11 +62,13 @@ def date

private

def expect_header_impl(key, content, contains = nil)
def expect_header_impl(key, content, contains = nil, matches = nil)
header = headers[key]
if header
if contains
expect(header.downcase).to include(content.downcase)
elsif matches
expect(header.downcase).to match(content)
else
expect(header.downcase).to eq(content.downcase)
end

0 comments on commit a413dfe

Please sign in to comment.