Class: RSpec::Http::HeaderStringMatcher

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) ⇒ HeaderStringMatcher

Returns a new instance of HeaderStringMatcher.



67
68
69
70
# File 'lib/rspec/http/header_matchers.rb', line 67

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

Instance Method Details

#descriptionObject



76
77
78
# File 'lib/rspec/http/header_matchers.rb', line 76

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

#failure_messageObject



80
81
82
# File 'lib/rspec/http/header_matchers.rb', line 80

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

#failure_message_when_negatedObject



84
85
86
# File 'lib/rspec/http/header_matchers.rb', line 84

def failure_message_when_negated
  "Expected the response header '#{header}' to have a value that is not '#{expected_value}'"
end

#validateObject



72
73
74
# File 'lib/rspec/http/header_matchers.rb', line 72

def validate
  expected_value.downcase == response[header].downcase
end