Sha256: d6c17100f7b9e15509d91d5f27e6e6dd79358f023df9addcd42c0da2eb1567b2
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require 'rest-core/test' describe RC::FollowRedirect do dry = Class.new do attr_accessor :status def call env yield(env.merge(RC::RESPONSE_STATUS => status, RC::RESPONSE_HEADERS => {'LOCATION' => 'location'})) end end.new app = RC::FollowRedirect.new(dry, 1) after do Muack.verify end [301, 302, 303, 307].each do |status| should "not follow redirect if reached max_redirects: #{status}" do dry.status = status app.call(RC::REQUEST_METHOD => :get, 'max_redirects' => 0){ |res| res[RC::RESPONSE_HEADERS]['LOCATION'].should.eq 'location' } end should "follow once: #{status}" do dry.status = status app.call(RC::REQUEST_METHOD => :get){ |res| res[RC::RESPONSE_HEADERS]['LOCATION'].should.eq 'location' } end end [200, 201, 404, 500].each do |status| should "not follow redirect if it's not a redirect status: #{status}" do dry.status = status app.call(RC::REQUEST_METHOD => :get, 'max_redirects' => 9){ |res| res[RC::RESPONSE_HEADERS]['LOCATION'].should.eq 'location' } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rest-core-3.0.0 | test/test_follow_redirect.rb |