Sha256: bbbc0639ca7c61183d56216ff4eb3a80b22af41b001a59795d85cf8349a288a9
Contents?: true
Size: 1.12 KB
Versions: 3
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 RR.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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rest-core-2.1.2 | test/test_follow_redirect.rb |
rest-core-2.1.1 | test/test_follow_redirect.rb |
rest-core-2.1.0 | test/test_follow_redirect.rb |