~ubuntu-branches/ubuntu/utopic/ruby-excon/utopic

« back to all changes in this revision

Viewing changes to tests/middlewares/redirect_follower_tests.rb

  • Committer: Package Import Robot
  • Author(s): Praveen Arimbrathodiyil
  • Date: 2014-01-14 18:44:24 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140114184424-3nx5mqudhzjpcrjs
Tags: 0.31.0-1
* Team upload
* New upstream release
* Refresh patches
* Bump standards version to 3.9.5 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Shindo.tests('Excon redirector support') do
 
2
  env_init
 
3
 
 
4
  tests("request(:method => :get, :path => '/old').body").returns('new') do
 
5
    Excon.stub(
 
6
      { :path => '/old' },
 
7
      {
 
8
        :headers  => { 'Location' => 'http://127.0.0.1:9292/new' },
 
9
        :body     => 'old',
 
10
        :status   => 301
 
11
      }
 
12
    )
 
13
 
 
14
    Excon.stub(
 
15
      { :path => '/new' },
 
16
      {
 
17
        :body     => 'new',
 
18
        :status   => 200
 
19
      }
 
20
    )
 
21
 
 
22
    Excon.get(
 
23
      'http://127.0.0.1:9292',
 
24
      :path         => '/old',
 
25
      :middlewares  => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
 
26
      :mock         => true
 
27
    ).body
 
28
  end
 
29
 
 
30
  env_restore
 
31
end
 
32
 
 
33
Shindo.tests('Excon redirect support for relative Location headers') do
 
34
  env_init
 
35
 
 
36
  tests("request(:method => :get, :path => '/old').body").returns('new') do
 
37
    Excon.stub(
 
38
      { :path => '/old' },
 
39
      {
 
40
        :headers  => { 'Location' => '/new' },
 
41
        :body     => 'old',
 
42
        :status   => 301
 
43
      }
 
44
    )
 
45
 
 
46
    Excon.stub(
 
47
      { :path => '/new' },
 
48
      {
 
49
        :body     => 'new',
 
50
        :status   => 200
 
51
      }
 
52
    )
 
53
 
 
54
    Excon.get(
 
55
      'http://127.0.0.1:9292',
 
56
      :path         => '/old',
 
57
      :middlewares  => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
 
58
      :mock         => true
 
59
    ).body
 
60
  end
 
61
 
 
62
  env_restore
 
63
end