Class: ResponseMatchers::ResponseLocationMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/responses.rb

Overview

Response matcher that examines ActionController::Response headers for the given location code

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ ResponseLocationMatcher

Returns a new instance of ResponseLocationMatcher.



61
62
63
# File 'lib/responses.rb', line 61

def initialize url
  @url = url
end

Instance Method Details

#failure_messageObject

What do we tell the user when it fails?



71
72
73
# File 'lib/responses.rb', line 71

def failure_message
  "expected the location header to be #{@url}"
end

#matches?(target) ⇒ Boolean

Does the given target object match the required location?

Returns:

  • (Boolean)


66
67
68
# File 'lib/responses.rb', line 66

def matches? target
  target.headers['Location'] == @url
end

#negative_failure_messageObject

What do we tell the user when it shouldn’t fail but does



76
77
78
# File 'lib/responses.rb', line 76

def negative_failure_message
  "expected the location header to be different to #{@url}"
end