Class: RSpec::Http::HeaderRegexpMatcher

Inherits:
HeaderPresenceMatcher show all
Defined in:
lib/rspec/http/header_matchers.rb

Instance Attribute Summary

Attributes inherited from HeaderPresenceMatcher

#expected_value, #header, #response

Instance Method Summary collapse

Methods inherited from HeaderPresenceMatcher

#matches?

Constructor Details

#initialize(header, expected_value) ⇒ HeaderRegexpMatcher

Returns a new instance of HeaderRegexpMatcher.



90
91
92
93
# File 'lib/rspec/http/header_matchers.rb', line 90

def initialize(header, expected_value)
  super(header)
  @expected_value =  expected_value
end

Instance Method Details

#descriptionObject



99
100
101
# File 'lib/rspec/http/header_matchers.rb', line 99

def description
  "Verify the value associated with '#{header}' matches '#{expected_value}"
end

#failure_messageObject



103
104
105
# File 'lib/rspec/http/header_matchers.rb', line 103

def failure_message
  "Expected the response header '#{header}' to have a value that matched #{expected_value.inspect} but it was '#{@response[header]}'"
end

#failure_message_when_negatedObject



107
108
109
# File 'lib/rspec/http/header_matchers.rb', line 107

def failure_message_when_negated
  "Expected the response header '#{header}' to have a value that does not match #{expected_value.inspect} but it was '#{@response[header]}'"
end

#validateObject



95
96
97
# File 'lib/rspec/http/header_matchers.rb', line 95

def validate
  expected_value =~ response[header]
end