rack-test 0.8.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98d93b9da867444521efc5c2d82d14b37c2b5743324865f96d2f6c0603ad8256
4
- data.tar.gz: 3f78a90b58f6de6582088185f995195841995e9b2a0a9518a93ecee081eb8416
3
+ metadata.gz: ffbb291753487a29727c09ba1b0b96cf873564798ef6f984931256b54043eadd
4
+ data.tar.gz: e9f40c35a2578f36cfbfffb17efc796543455c2617961350790f1742653566c0
5
5
  SHA512:
6
- metadata.gz: 3bd23e7ffcfa4ab19ad2966f36bcab31f49f3ea7f819fb81f15ce874437d8c6b96c6844f40499512042166b007d940b819b44e8d978ba4001f77fe515225f529
7
- data.tar.gz: 9d0479de503ae1a74f2aa9263b39dfdabf1745c17bed3fc18e6aaf757bf0b7428510f26a08c0021090ec98f8125eca74fb19e9f7f19eef41a94dd9847a441472
6
+ metadata.gz: 3c2735a0f2564b979b9b5fcd9f5f952e7c0bf0b3f31071271089b8df2b34e18436e516a38bf3d708082b07169bbd79612a6286610b072970bb1c79636c31d1e9
7
+ data.tar.gz: aa3444f42ebb904a6b33c03cfdb3787cef34acbe96171569395123483b5b0df66401d959576990d90ced9e587fdbfbba049f42884cec2696549ea685b6643baa
data/History.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 1.0.0 / 2018-03-27
2
+
3
+ * Breaking changes:
4
+ * Always set CONTENT_TYPE for non-GET requests
5
+ (Per Lundberg #223)
6
+
7
+ * Minor enhancements / bug fixes:
8
+ * Create tempfile using the basename without extension
9
+ (Edouard Chin #201)
10
+ * Save `session` during `follow_redirect!`
11
+ (Alexander Popov #218)
12
+ * Document how to use URL params with DELETE method
13
+ (Timur Platonov #220)
14
+
1
15
  ## 0.8.3 / 2018-02-27
2
16
 
3
17
  * Bug fixes:
data/README.md CHANGED
@@ -28,6 +28,10 @@ to build on.
28
28
 
29
29
  If you are using Ruby 1.8, 1.9 or JRuby 1.7, use rack-test 0.6.3.
30
30
 
31
+ ## Known incompatibilites
32
+
33
+ * `rack-test >= 0.71` _does not_ work with older Capybara versions (`< 2.17`). See [#214](https://github.com/rack-test/rack-test/issues/214) for more details.
34
+
31
35
  ## Examples
32
36
  (The examples use `Test::Unit` but it's equally possible to use `rack-test` with other testing frameworks like `rspec`.)
33
37
 
@@ -72,6 +76,10 @@ class HomepageTest < Test::Unit::TestCase
72
76
  # parameters, so make sure that `json` below is already a JSON-serialized string.
73
77
  post(uri, json, { 'CONTENT_TYPE' => 'application/json' })
74
78
  end
79
+
80
+ def delete_with_url_params_and_body
81
+ delete '/?foo=bar', JSON.generate('baz' => 'zot')
82
+ end
75
83
  end
76
84
  ```
77
85
 
@@ -106,7 +114,7 @@ gem install rack-test
106
114
  Or via Bundler:
107
115
 
108
116
  ```
109
- gem 'rack-test', require: 'rack/test'
117
+ gem 'rack-test'
110
118
  ```
111
119
 
112
120
  Or to install unreleased version via Bundler:
@@ -188,11 +188,17 @@ module Rack
188
188
  unless last_response.redirect?
189
189
  raise Error, 'Last response was not a redirect. Cannot follow_redirect!'
190
190
  end
191
- if last_response.status == 307
192
- send(last_request.request_method.downcase.to_sym, last_response['Location'], last_request.params, 'HTTP_REFERER' => last_request.url)
193
- else
194
- get(last_response['Location'], {}, 'HTTP_REFERER' => last_request.url)
195
- end
191
+ request_method, params =
192
+ if last_response.status == 307
193
+ [last_request.request_method.downcase.to_sym, last_request.params]
194
+ else
195
+ [:get, {}]
196
+ end
197
+ send(
198
+ request_method, last_response['Location'], params,
199
+ 'HTTP_REFERER' => last_request.url,
200
+ 'rack.session' => last_request.session
201
+ )
196
202
  end
197
203
 
198
204
  private
@@ -227,7 +233,7 @@ module Rack
227
233
  uri.query = [uri.query, build_nested_query(params)].compact.reject { |v| v == '' }.join('&')
228
234
  end
229
235
  elsif !env.key?(:input)
230
- env['CONTENT_TYPE'] ||= 'application/x-www-form-urlencoded' unless params.nil?
236
+ env['CONTENT_TYPE'] ||= 'application/x-www-form-urlencoded'
231
237
 
232
238
  if params.is_a?(Hash)
233
239
  if data = build_multipart(params)
@@ -235,6 +241,8 @@ module Rack
235
241
  env['CONTENT_LENGTH'] ||= data.length.to_s
236
242
  env['CONTENT_TYPE'] = "multipart/form-data; boundary=#{MULTIPART_BOUNDARY}"
237
243
  else
244
+ # NB: We do not need to set CONTENT_LENGTH here;
245
+ # Rack::ContentLength will determine it automatically.
238
246
  env[:input] = params_to_string(params)
239
247
  end
240
248
  else
@@ -106,6 +106,8 @@ module Rack
106
106
  end
107
107
 
108
108
  class CookieJar # :nodoc:
109
+ DELIMITER = '; '.freeze
110
+
109
111
  # :api: private
110
112
  def initialize(cookies = [], default_host = DEFAULT_HOST)
111
113
  @default_host = default_host
@@ -158,7 +160,7 @@ module Rack
158
160
 
159
161
  # :api: private
160
162
  def for(uri)
161
- hash_for(uri).values.map(&:raw).join(';')
163
+ hash_for(uri).values.map(&:raw).join(DELIMITER)
162
164
  end
163
165
 
164
166
  def to_hash
@@ -71,8 +71,9 @@ module Rack
71
71
  raise "#{path} file does not exist" unless ::File.exist?(path)
72
72
 
73
73
  @original_filename = ::File.basename(path)
74
+ extension = ::File.extname(@original_filename)
74
75
 
75
- @tempfile = Tempfile.new([@original_filename, ::File.extname(path)])
76
+ @tempfile = Tempfile.new([::File.basename(@original_filename, extension), extension])
76
77
  @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding)
77
78
 
78
79
  ObjectSpace.define_finalizer(self, self.class.finalize(@tempfile))
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Test
3
- VERSION = '0.8.3'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack