Sha256: ec2c15ae92a2a451668e9a41f01da33735856dc4e77145e5fa26e87a67b3db11

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

Shindo.tests('Excon redirector support') do
  env_init

  connection = Excon.new(
    'http://127.0.0.1:9292',
    :middlewares  => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
    :mock         => true
  )

  Excon.stub(
    { :path => '/old' },
    {
      :headers  => { 'Location' => 'http://127.0.0.1:9292/new' },
      :body     => 'old',
      :status   => 301
    }
  )

  Excon.stub(
    { :path => '/new' },
    {
      :body     => 'new',
      :status   => 200
    }
  )

  tests("request(:method => :get, :path => '/old').body").returns('new') do
    connection.request(:method => :get, :path => '/old').body
  end

  env_restore
end

Shindo.tests('Excon redirect support for relative Location headers') do
  env_init
  
  connection = Excon.new(
    'http://127.0.0.1:9292',
    :middlewares  => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
    :mock         => true
  )

  Excon.stub(
    { :path => '/old' },
    {
      :headers  => { 'Location' => '/new' },
      :body     => 'old',
      :status   => 301
    }
  )

  Excon.stub(
    { :path => '/new' },
    {
      :body     => 'new',
      :status   => 200
    }
  )

  tests("request(:method => :get, :path => '/old').body").returns('new') do
    connection.request(:method => :get, :path => '/old').body
  end
  
  env_restore
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
excon-0.30.0 tests/middlewares/redirect_follower_tests.rb