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.



69
70
71
# File 'lib/responses.rb', line 69

def initialize url
  @url = url
end

Instance Method Details

#failure_messageObject

What do we tell the user when it fails?



79
80
81
82
83
84
# File 'lib/responses.rb', line 79

def failure_message
  a = <<-EOF
  expected the location header to be #{@target_url.inspect}
                      instead it was #{@url.inspect}
  EOF
end

#matches?(target) ⇒ Boolean

Does the given target object match the required location?

Returns:

  • (Boolean)


74
75
76
# File 'lib/responses.rb', line 74

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

#negative_failure_messageObject

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



87
88
89
# File 'lib/responses.rb', line 87

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