module AkamaiRSpec::Helpers::ChainableRedirect
Public Class Methods
included(other)
click to toggle source
# File lib/akamai_rspec/helpers/chainable_redirect.rb, line 5 def self.included(other) other.chain :then do |matcher| (@and_then_matchers ||= []).push(matcher) end end
Public Instance Methods
failure_message()
click to toggle source
Calls superclass method
# File lib/akamai_rspec/helpers/chainable_redirect.rb, line 45 def failure_message @and_then_error || super end
redirect(url, expected_location, expected_response_code, headers)
click to toggle source
# File lib/akamai_rspec/helpers/chainable_redirect.rb, line 18 def redirect(url, expected_location, expected_response_code, headers) response = AkamaiRSpec::Request.get(url, headers) if expected_response_code.kind_of?(Array) fail "Response was #{response.inspect}, expected code #{expected_response_code}" unless expected_response_code.include? response.code unless expected_location === response.headers[:location] fail "redirect location was #{response.headers[:location]} (expected #{expected_location})" end else fail "Response was #{response.inspect}, expected code #{expected_response_code}" unless response.code == expected_response_code unless expected_location === response.headers[:location] fail "redirect location was #{response.headers[:location]} (expected #{expected_location})" end end if @and_then_matchers begin @and_then_matchers.each {|matcher| expect(response.headers[:location]).to matcher} rescue Exception => e @and_then_error = e return false end end true end
with_and_without_tls(url)
click to toggle source
# File lib/akamai_rspec/helpers/chainable_redirect.rb, line 11 def with_and_without_tls(url) url = "http://#{url}" unless URI(url).scheme url = url.gsub(/^https:/i, 'http:') secure = url.gsub(/^http:/i, 'https:') return secure, url end