faraday_middleware 0.8.8 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  platforms :mri_19 do
4
4
  gem 'simplecov'
5
- gem 'cane', '>= 0.3'
5
+ gem 'cane', '~> 2.2.2'
6
6
  end
7
7
 
8
8
  gem 'json', :platforms => [:ruby_18, :jruby]
data/Rakefile CHANGED
@@ -14,14 +14,16 @@ task :enable_coverage do
14
14
  ENV['COVERAGE'] = 'yes'
15
15
  end
16
16
 
17
+ desc %(Run Test::Unit tests)
17
18
  task :test do
18
19
  sh 'ruby', '-Ilib', 'spec/caching_test.rb'
19
20
  end
20
21
 
22
+ desc %(Check code quality metrics with Cane)
21
23
  task :quality do
22
24
  sh 'cane',
23
- '--abc-max=10',
24
- '--style-measure=100',
25
+ '--abc-max=15',
26
+ '--style-measure=110',
25
27
  '--gte=coverage/covered_percent,99',
26
- '--max-violations=2'
28
+ '--max-violations=0'
27
29
  end
@@ -4,12 +4,14 @@ module FaradayMiddleware
4
4
  autoload :OAuth, 'faraday_middleware/request/oauth'
5
5
  autoload :OAuth2, 'faraday_middleware/request/oauth2'
6
6
  autoload :EncodeJson, 'faraday_middleware/request/encode_json'
7
+ autoload :MethodOverride, 'faraday_middleware/request/method_override'
7
8
  autoload :Mashify, 'faraday_middleware/response/mashify'
8
9
  autoload :Rashify, 'faraday_middleware/response/rashify'
9
10
  autoload :ParseJson, 'faraday_middleware/response/parse_json'
10
11
  autoload :ParseXml, 'faraday_middleware/response/parse_xml'
11
12
  autoload :ParseMarshal, 'faraday_middleware/response/parse_marshal'
12
13
  autoload :ParseYaml, 'faraday_middleware/response/parse_yaml'
14
+ autoload :ParseDates, 'faraday_middleware/response/parse_dates'
13
15
  autoload :Caching, 'faraday_middleware/response/caching'
14
16
  autoload :Chunked, 'faraday_middleware/response/chunked'
15
17
  autoload :RackCompatible, 'faraday_middleware/rack_compatible'
@@ -20,7 +22,8 @@ module FaradayMiddleware
20
22
  Faraday.register_middleware :request,
21
23
  :oauth => lambda { OAuth },
22
24
  :oauth2 => lambda { OAuth2 },
23
- :json => lambda { EncodeJson }
25
+ :json => lambda { EncodeJson },
26
+ :method_override => lambda { MethodOverride }
24
27
 
25
28
  Faraday.register_middleware :response,
26
29
  :mashify => lambda { Mashify },
@@ -30,6 +33,7 @@ module FaradayMiddleware
30
33
  :xml => lambda { ParseXml },
31
34
  :marshal => lambda { ParseMarshal },
32
35
  :yaml => lambda { ParseYaml },
36
+ :dates => lambda { ParseDates },
33
37
  :caching => lambda { Caching },
34
38
  :follow_redirects => lambda { FollowRedirects },
35
39
  :chunked => lambda { Chunked }
@@ -0,0 +1,51 @@
1
+ require 'faraday'
2
+
3
+ module FaradayMiddleware
4
+ # Public: Writes the original HTTP method to "X-Http-Method-Override" header
5
+ # and sends the request as POST.
6
+ #
7
+ # This can be used to work around technical issues with making non-POST
8
+ # requests, e.g. faulty HTTP client or server router.
9
+ #
10
+ # This header is recognized in Rack apps by default, courtesy of the
11
+ # Rack::MethodOverride module. See
12
+ # http://rack.rubyforge.org/doc/classes/Rack/MethodOverride.html
13
+ class MethodOverride < Faraday::Middleware
14
+
15
+ HEADER = "X-Http-Method-Override".freeze
16
+
17
+ # Public: Initialize the middleware.
18
+ #
19
+ # app - the Faraday app to wrap
20
+ # options - (optional)
21
+ # :rewrite - Array of HTTP methods to rewrite
22
+ # (default: all but GET and POST)
23
+ def initialize(app, options = nil)
24
+ super(app)
25
+ @methods = options && options.fetch(:rewrite).map { |method|
26
+ method = method.downcase if method.respond_to? :downcase
27
+ method.to_sym
28
+ }
29
+ end
30
+
31
+ def call(env)
32
+ method = env[:method]
33
+ rewrite_request(env, method) if rewrite_request?(method)
34
+ @app.call(env)
35
+ end
36
+
37
+ def rewrite_request?(method)
38
+ if @methods.nil? or @methods.empty?
39
+ method != :get and method != :post
40
+ else
41
+ @methods.include? method
42
+ end
43
+ end
44
+
45
+ # Internal: Write the original HTTP method to header, change method to POST.
46
+ def rewrite_request(env, original_method)
47
+ env[:request_headers][HEADER] = original_method.to_s.upcase
48
+ env[:method] = :post
49
+ end
50
+ end
51
+ end
@@ -34,7 +34,7 @@ module FaradayMiddleware
34
34
  # words, it doesn't support parallelism.
35
35
  class FollowRedirects < Faraday::Middleware
36
36
  # HTTP methods for which 30x redirects can be followed
37
- ALLOWED_METHODS = Set.new [:get, :post, :put, :patch, :delete]
37
+ ALLOWED_METHODS = Set.new [:head, :options, :get, :post, :put, :patch, :delete]
38
38
  # HTTP redirect status codes that this middleware implements
39
39
  REDIRECT_CODES = Set.new [301, 302, 303, 307]
40
40
  # Keys in env hash which will get cleared between requests
@@ -68,6 +68,9 @@ module FaradayMiddleware
68
68
  private
69
69
 
70
70
  def transform_into_get?(response)
71
+ return false if [:head, :options].include? response.env[:method]
72
+ # Never convert head or options to a get. That would just be silly.
73
+
71
74
  !@replay_request_codes.include? response.status
72
75
  end
73
76
 
@@ -87,7 +90,10 @@ module FaradayMiddleware
87
90
 
88
91
  def update_env(env, request_body, response)
89
92
  env[:url] += response['location']
90
- env[:request_headers][:cookies] = keep_cookies(env) if @options[:cookies]
93
+ if @options[:cookies]
94
+ cookies = keep_cookies(env)
95
+ env[:request_headers][:cookies] = cookies unless cookies.nil?
96
+ end
91
97
 
92
98
  if transform_into_get?(response)
93
99
  env[:method] = :get
@@ -1,3 +1,3 @@
1
1
  module FaradayMiddleware
2
- VERSION = "0.8.8"
2
+ VERSION = "0.9.0"
3
3
  end
data/spec/caching_test.rb CHANGED
@@ -152,4 +152,4 @@ class HttpCachingTest < Test::Unit::TestCase
152
152
  assert_equal 'request:2', post('/').body
153
153
  assert_equal 'request:3', post('/').body
154
154
  end
155
- end unless defined? RUBY_ENGINE and "rbx" == RUBY_ENGINE # rbx bug #1522
155
+ end unless defined? RUBY_ENGINE and "rbx" == RUBY_ENGINE # rbx bug #1522
data/spec/chunked_spec.rb CHANGED
@@ -4,15 +4,15 @@ require 'faraday_middleware/response/chunked'
4
4
  describe FaradayMiddleware::Chunked, :type => :response do
5
5
  context "no transfer-encoding" do
6
6
  it "doesn't change nil body" do
7
- process(nil).body.should be_nil
7
+ expect(process(nil).body).to be_nil
8
8
  end
9
9
 
10
10
  it "doesn't change an empty body" do
11
- process('').body.should eql('')
11
+ expect(process('').body).to eq('')
12
12
  end
13
13
 
14
14
  it "doesn't change a normal body" do
15
- process('asdf').body.should eql('asdf')
15
+ expect(process('asdf').body).to eq('asdf')
16
16
  end
17
17
  end
18
18
 
@@ -20,15 +20,15 @@ describe FaradayMiddleware::Chunked, :type => :response do
20
20
  let(:headers) { {"transfer-encoding" => "gzip"}}
21
21
 
22
22
  it "doesn't change nil body" do
23
- process(nil).body.should be_nil
23
+ expect(process(nil).body).to be_nil
24
24
  end
25
25
 
26
26
  it "doesn't change an empty body" do
27
- process('').body.should eql('')
27
+ expect(process('').body).to eq('')
28
28
  end
29
29
 
30
30
  it "doesn't change a normal body" do
31
- process('asdf').body.should eql('asdf')
31
+ expect(process('asdf').body).to eq('asdf')
32
32
  end
33
33
  end
34
34
 
@@ -36,35 +36,35 @@ describe FaradayMiddleware::Chunked, :type => :response do
36
36
  let(:headers) { {"transfer-encoding" => "chunked"}}
37
37
 
38
38
  it "doesn't change nil body" do
39
- process(nil).body.should be_nil
39
+ expect(process(nil).body).to be_nil
40
40
  end
41
41
 
42
42
  it "doesn't change an empty body" do
43
- process('').body.should eql('')
43
+ expect(process('').body).to eq('')
44
44
  end
45
45
 
46
46
  it "parses a basic chunked body" do
47
- process("10\r\nasdfghjklasdfghj\r\n0\r\n").body.should eql('asdfghjklasdfghj')
47
+ expect(process("10\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
48
48
  end
49
49
 
50
50
  it "parses a chunked body with no ending chunk" do
51
- process("10\r\nasdfghjklasdfghj\r\n").body.should eql('asdfghjklasdfghj')
51
+ expect(process("10\r\nasdfghjklasdfghj\r\n").body).to eq('asdfghjklasdfghj')
52
52
  end
53
53
 
54
54
  it "parses a chunked body with no trailing CRLF on the data chunk" do
55
- process("10\r\nasdfghjklasdfghj0\r\n").body.should eql('asdfghjklasdfghj')
55
+ expect(process("10\r\nasdfghjklasdfghj0\r\n").body).to eq('asdfghjklasdfghj')
56
56
  end
57
57
 
58
58
  it "parses a chunked body with an extension" do
59
- process("10;foo=bar\r\nasdfghjklasdfghj\r\n0\r\n").body.should eql('asdfghjklasdfghj')
59
+ expect(process("10;foo=bar\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
60
60
  end
61
61
 
62
62
  it "parses a chunked body with two extensions" do
63
- process("10;foo=bar;bar=baz\r\nasdfghjklasdfghj\r\n0\r\n").body.should eql('asdfghjklasdfghj')
63
+ expect(process("10;foo=bar;bar=baz\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
64
64
  end
65
65
 
66
66
  it "parses a chunked body with two chunks" do
67
- process("8\r\nasdfghjk\r\n8\r\nlasdfghj\r\n0\r\n").body.should eql('asdfghjklasdfghj')
67
+ expect(process("8\r\nasdfghjk\r\n8\r\nlasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
68
68
  end
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ describe FaradayMiddleware::Chunked, :type => :response do
72
72
  let(:headers) { {"transfer-encoding" => "chunked,chunked"}}
73
73
 
74
74
  it "parses a basic chunked body" do
75
- process("10\r\nasdfghjklasdfghj\r\n0\r\n").body.should eql('asdfghjklasdfghj')
75
+ expect(process("10\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
76
76
  end
77
77
  end
78
78
  end
@@ -17,11 +17,11 @@ describe FaradayMiddleware::EncodeJson do
17
17
  let(:result) { process(nil) }
18
18
 
19
19
  it "doesn't change body" do
20
- result_body.should be_nil
20
+ expect(result_body).to be_nil
21
21
  end
22
22
 
23
23
  it "doesn't add content type" do
24
- result_type.should be_nil
24
+ expect(result_type).to be_nil
25
25
  end
26
26
  end
27
27
 
@@ -29,11 +29,11 @@ describe FaradayMiddleware::EncodeJson do
29
29
  let(:result) { process('') }
30
30
 
31
31
  it "doesn't change body" do
32
- result_body.should be_empty
32
+ expect(result_body).to be_empty
33
33
  end
34
34
 
35
35
  it "doesn't add content type" do
36
- result_type.should be_nil
36
+ expect(result_type).to be_nil
37
37
  end
38
38
  end
39
39
 
@@ -41,11 +41,11 @@ describe FaradayMiddleware::EncodeJson do
41
41
  let(:result) { process('{"a":1}') }
42
42
 
43
43
  it "doesn't change body" do
44
- result_body.should eql('{"a":1}')
44
+ expect(result_body).to eq('{"a":1}')
45
45
  end
46
46
 
47
47
  it "adds content type" do
48
- result_type.should eql('application/json')
48
+ expect(result_type).to eq('application/json')
49
49
  end
50
50
  end
51
51
 
@@ -53,11 +53,11 @@ describe FaradayMiddleware::EncodeJson do
53
53
  let(:result) { process({:a => 1}) }
54
54
 
55
55
  it "encodes body" do
56
- result_body.should eql('{"a":1}')
56
+ expect(result_body).to eq('{"a":1}')
57
57
  end
58
58
 
59
59
  it "adds content type" do
60
- result_type.should eql('application/json')
60
+ expect(result_type).to eq('application/json')
61
61
  end
62
62
  end
63
63
 
@@ -65,7 +65,7 @@ describe FaradayMiddleware::EncodeJson do
65
65
  let(:result) { process({}) }
66
66
 
67
67
  it "encodes body" do
68
- result_body.should eql('{}')
68
+ expect(result_body).to eq('{}')
69
69
  end
70
70
  end
71
71
 
@@ -73,11 +73,11 @@ describe FaradayMiddleware::EncodeJson do
73
73
  let(:result) { process({:a => 1}, 'application/json; charset=utf-8') }
74
74
 
75
75
  it "encodes body" do
76
- result_body.should eql('{"a":1}')
76
+ expect(result_body).to eq('{"a":1}')
77
77
  end
78
78
 
79
79
  it "doesn't change content type" do
80
- result_type.should eql('application/json; charset=utf-8')
80
+ expect(result_type).to eq('application/json; charset=utf-8')
81
81
  end
82
82
  end
83
83
 
@@ -85,11 +85,11 @@ describe FaradayMiddleware::EncodeJson do
85
85
  let(:result) { process({:a => 1}, 'application/xml; charset=utf-8') }
86
86
 
87
87
  it "doesn't change body" do
88
- result_body.should eql({:a => 1})
88
+ expect(result_body).to eq({:a => 1})
89
89
  end
90
90
 
91
91
  it "doesn't change content type" do
92
- result_type.should eql('application/xml; charset=utf-8')
92
+ expect(result_type).to eq('application/xml; charset=utf-8')
93
93
  end
94
94
  end
95
95
  end
@@ -8,27 +8,33 @@ Faraday::Adapter::Test::Stubs.class_eval { public :new_stub }
8
8
  describe FaradayMiddleware::FollowRedirects do
9
9
  let(:middleware_options) { Hash.new }
10
10
 
11
- shared_examples_for 'a successful redirection' do |status_code|
11
+ shared_examples_for "a successful redirection" do |status_code|
12
12
  it "follows the redirection for a GET request" do
13
- connection do |stub|
13
+ expect(connection do |stub|
14
14
  stub.get('/permanent') { [status_code, {'Location' => '/found'}, ''] }
15
15
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, 'fin'] }
16
- end.get('/permanent').body.should eql 'fin'
16
+ end.get('/permanent').body).to eq 'fin'
17
17
  end
18
18
 
19
- [:head, :options].each do |method|
20
- it "returning the response headers for a #{method.to_s.upcase} request" do
21
- connection do |stub|
22
- stub.new_stub(method, '/permanent') { [status_code, {'Location' => '/found'}, ''] }
23
- end.run_request(method, '/permanent', nil, nil).headers['Location'].should eql('/found')
24
- end
19
+ it "follows the redirection for a HEAD request" do
20
+ expect(connection do |stub|
21
+ stub.head('/permanent') { [status_code, {'Location' => '/found'}, ''] }
22
+ stub.head('/found') { [200, {'Content-Type' => 'text/plain'}, ''] }
23
+ end.head('/permanent').status).to eq 200
24
+ end
25
+
26
+ it "follows the redirection for a OPTIONS request" do
27
+ expect(connection do |stub|
28
+ stub.new_stub(:options, '/permanent') { [status_code, {'Location' => '/found'}, ''] }
29
+ stub.new_stub(:options, '/found') { [200, {'Content-Type' => 'text/plain'}, ''] }
30
+ end.run_request(:options, '/permanent', nil, nil).status).to eq 200
25
31
  end
26
32
  end
27
33
 
28
- shared_examples_for 'a forced GET redirection' do |status_code|
34
+ shared_examples_for "a forced GET redirection" do |status_code|
29
35
  [:put, :post, :delete, :patch].each do |method|
30
36
  it "a #{method.to_s.upcase} request is converted to a GET" do
31
- connection = connection do |stub|
37
+ expect(connection do |stub|
32
38
  stub.new_stub(method, '/redirect') {
33
39
  [status_code, {'Location' => '/found'}, 'elsewhere']
34
40
  }
@@ -36,13 +42,13 @@ describe FaradayMiddleware::FollowRedirects do
36
42
  body = env[:body] and body.empty? && (body = nil)
37
43
  [200, {'Content-Type' => 'text/plain'}, body.inspect]
38
44
  }
39
- end.run_request(method, '/redirect', 'request data', nil).body.should eql('nil')
45
+ end.run_request(method, '/redirect', 'request data', nil).body).to eq('nil')
40
46
  end
41
47
  end
42
48
  end
43
49
 
44
- shared_examples_for 'a replayed redirection' do |status_code|
45
- it 'redirects with the original request headers' do
50
+ shared_examples_for "a replayed redirection" do |status_code|
51
+ it "redirects with the original request headers" do
46
52
  conn = connection do |stub|
47
53
  stub.get('/redirect') {
48
54
  [status_code, {'Location' => '/found'}, '']
@@ -56,15 +62,15 @@ describe FaradayMiddleware::FollowRedirects do
56
62
  req.headers['X-Test-Value'] = 'success'
57
63
  }
58
64
 
59
- response.body.should eql('success')
65
+ expect(response.body).to eq('success')
60
66
  end
61
67
 
62
68
  [:put, :post, :delete, :patch].each do |method|
63
69
  it "replays a #{method.to_s.upcase} request" do
64
- connection do |stub|
70
+ expect(connection do |stub|
65
71
  stub.new_stub(method, '/redirect') { [status_code, {'Location' => '/found'}, ''] }
66
72
  stub.new_stub(method, '/found') { [200, {'Content-Type' => 'text/plain'}, 'fin'] }
67
- end.run_request(method, '/redirect', nil, nil).body.should eql 'fin'
73
+ end.run_request(method, '/redirect', nil, nil).body).to eq 'fin'
68
74
  end
69
75
  end
70
76
 
@@ -80,32 +86,32 @@ describe FaradayMiddleware::FollowRedirects do
80
86
  end
81
87
 
82
88
  response = conn.run_request(method, '/redirect', 'original data', nil)
83
- response.body.should eql('original data')
89
+ expect(response.body).to eq('original data')
84
90
  end
85
91
  end
86
92
  end
87
93
 
88
94
 
89
95
  it "returns non-redirect response results" do
90
- connection do |stub|
96
+ expect(connection do |stub|
91
97
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, 'fin'] }
92
- end.get('/found').body.should eql 'fin'
98
+ end.get('/found').body).to eq 'fin'
93
99
  end
94
100
 
95
101
  it "follows a single redirection" do
96
- connection do |stub|
102
+ expect(connection do |stub|
97
103
  stub.get('/') { [301, {'Location' => '/found'}, ''] }
98
104
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, 'fin'] }
99
- end.get('/').body.should eql 'fin'
105
+ end.get('/').body).to eq 'fin'
100
106
  end
101
107
 
102
108
  it "follows many redirections" do
103
- connection do |stub|
109
+ expect(connection do |stub|
104
110
  stub.get('/') { [301, {'Location' => '/redirect1'}, ''] }
105
111
  stub.get('/redirect1') { [301, {'Location' => '/redirect2'}, ''] }
106
112
  stub.get('/redirect2') { [301, {'Location' => '/found'}, ''] }
107
113
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, 'fin'] }
108
- end.get('/').body.should eql 'fin'
114
+ end.get('/').body).to eq 'fin'
109
115
  end
110
116
 
111
117
  it "raises a FaradayMiddleware::RedirectLimitReached after 3 redirections (by default)" do
@@ -117,7 +123,7 @@ describe FaradayMiddleware::FollowRedirects do
117
123
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, 'fin'] }
118
124
  end
119
125
 
120
- expect { conn.get('/') }.to raise_error(FaradayMiddleware::RedirectLimitReached)
126
+ expect{ conn.get('/') }.to raise_error(FaradayMiddleware::RedirectLimitReached)
121
127
  end
122
128
 
123
129
  it "raises a FaradayMiddleware::RedirectLimitReached after the initialized limit" do
@@ -127,58 +133,65 @@ describe FaradayMiddleware::FollowRedirects do
127
133
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, 'fin'] }
128
134
  end
129
135
 
130
- expect { conn.get('/') }.to raise_error(FaradayMiddleware::RedirectLimitReached)
136
+ expect{ conn.get('/') }.to raise_error(FaradayMiddleware::RedirectLimitReached)
131
137
  end
132
138
 
133
- context 'when cookies option' do
139
+ context "when cookies option" do
134
140
 
135
141
  let(:cookies) { 'cookie1=abcdefg; cookie2=1234567; cookie3=awesome' }
136
142
 
137
143
  context "is :all" do
138
144
  it "puts all cookies from the response into the next request" do
139
- conn = connection(:cookies => :all) do |stub|
145
+ expect(connection(:cookies => :all) do |stub|
140
146
  stub.get('/') { [301, {'Location' => '/found', 'Cookies' => cookies }, ''] }
141
147
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, ''] }
142
- end.get('/').env[:request_headers][:cookies].should == cookies
148
+ end.get('/').env[:request_headers][:cookies]).to eq(cookies)
149
+ end
150
+
151
+ it "not set cookies header on request when response has no cookies" do
152
+ expect(connection(:cookies => :all) do |stub|
153
+ stub.get('/') { [301, {'Location' => '/found'}, ''] }
154
+ stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, ''] }
155
+ end.get('/').env[:request_headers].has_key?('Cookies')).to eq(false)
143
156
  end
144
157
  end
145
158
 
146
159
  context "is an array of cookie names" do
147
160
  it "puts selected cookies from the response into the next request" do
148
- conn = connection(:cookies => ['cookie2']) do |stub|
161
+ expect(connection(:cookies => ['cookie2']) do |stub|
149
162
  stub.get('/') { [301, {'Location' => '/found', 'Cookies' => cookies }, ''] }
150
163
  stub.get('/found') { [200, {'Content-Type' => 'text/plain'}, ''] }
151
- end.get('/').env[:request_headers][:cookies].should == 'cookie2=1234567'
164
+ end.get('/').env[:request_headers][:cookies]).to eq('cookie2=1234567')
152
165
  end
153
166
  end
154
167
  end
155
168
 
156
- context 'for an HTTP 301 response' do
157
- it_should_behave_like 'a successful redirection', 301
158
- it_should_behave_like 'a forced GET redirection', 301
169
+ context "for an HTTP 301 response" do
170
+ it_behaves_like 'a successful redirection', 301
171
+ it_behaves_like 'a forced GET redirection', 301
159
172
  end
160
173
 
161
- context 'for an HTTP 302 response' do
162
- it_should_behave_like 'a successful redirection', 302
174
+ context "for an HTTP 302 response" do
175
+ it_behaves_like 'a successful redirection', 302
163
176
 
164
- context 'by default' do
165
- it_should_behave_like 'a forced GET redirection', 302
177
+ context "by default" do
178
+ it_behaves_like 'a forced GET redirection', 302
166
179
  end
167
180
 
168
- context 'with standards compliancy enabled' do
181
+ context "with standards compliancy enabled" do
169
182
  let(:middleware_options) { { :standards_compliant => true } }
170
- it_should_behave_like 'a replayed redirection', 302
183
+ it_behaves_like 'a replayed redirection', 302
171
184
  end
172
185
  end
173
186
 
174
- context 'for an HTTP 303 response' do
175
- it_should_behave_like 'a successful redirection', 303
176
- it_should_behave_like 'a forced GET redirection', 303
187
+ context "for an HTTP 303 response" do
188
+ it_behaves_like 'a successful redirection', 303
189
+ it_behaves_like 'a forced GET redirection', 303
177
190
  end
178
191
 
179
- context 'for an HTTP 307 response' do
180
- it_should_behave_like 'a successful redirection', 307
181
- it_should_behave_like 'a replayed redirection', 307
192
+ context "for an HTTP 307 response" do
193
+ it_behaves_like 'a successful redirection', 307
194
+ it_behaves_like 'a replayed redirection', 307
182
195
  end
183
196
 
184
197
  # checks env hash in request phase for basic validity