Class: Reins::Spec::Matchers::RedirectTo
- Inherits:
-
Object
- Object
- Reins::Spec::Matchers::RedirectTo
- Defined in:
- lib/reins/spec/matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(url) ⇒ RedirectTo
constructor
A new instance of RedirectTo.
- #matches?(response) ⇒ Boolean
Constructor Details
#initialize(url) ⇒ RedirectTo
Returns a new instance of RedirectTo.
36 37 38 |
# File 'lib/reins/spec/matchers.rb', line 36 def initialize(url) @expected_url = url end |
Instance Method Details
#failure_message ⇒ Object
47 48 49 50 |
# File 'lib/reins/spec/matchers.rb', line 47 def "expected a 3xx redirect to #{@expected_url.inspect}, " \ "got status #{@actual_status} location #{@actual_location.inspect}" end |
#matches?(response) ⇒ Boolean
40 41 42 43 44 45 |
# File 'lib/reins/spec/matchers.rb', line 40 def matches?(response) @actual_status = response.status location_header = response.headers["Location"] || response.headers["location"] @actual_location = location_header (300..399).cover?(@actual_status) && @actual_location == @expected_url end |