rack-test 0.8.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +27 -0
- data/README.md +13 -3
- data/lib/rack/test/cookie_jar.rb +3 -1
- data/lib/rack/test/uploaded_file.rb +2 -1
- data/lib/rack/test/version.rb +1 -1
- data/lib/rack/test.rb +21 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e25e843eada244c949970f14897865edcf1687b17889560923e32306632423
|
4
|
+
data.tar.gz: ac325910df89080a58b47b7ec9f7e84c552a597d09a0ed3e1c5600a7cc4a6d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86f02b6cc8a0c7bbebbe64612e174f250abce84458ab732457e3b132f70f93b31f0ca791b75c167796690d3293fb4de02d895be85baeada4b619977b1b1ac39
|
7
|
+
data.tar.gz: 002d971754b2ac28d329c8b7231d97068939e6b0e17d24d7d7d87088ac15cff4597d560843168a0289098e58639bc39f9c3b22129550a39e0d5f07a03413d70b
|
data/History.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
## 1.1.0 / 2018-07-21
|
2
|
+
|
3
|
+
* Breaking changes:
|
4
|
+
* None
|
5
|
+
|
6
|
+
* Minor enhancements / new functionality:
|
7
|
+
* [GitHub] Added configuration for Stale (Per Lundberg #232)
|
8
|
+
* follow_direct: Include rack.session.options (Mark Edmondson #233)
|
9
|
+
* [CI] Add simplecov (fatkodima #227)
|
10
|
+
|
11
|
+
Bug fixes:
|
12
|
+
* Follow relative locations correctly. (Samuel Williams #230)
|
13
|
+
|
14
|
+
## 1.0.0 / 2018-03-27
|
15
|
+
|
16
|
+
* Breaking changes:
|
17
|
+
* Always set CONTENT_TYPE for non-GET requests
|
18
|
+
(Per Lundberg #223)
|
19
|
+
|
20
|
+
* Minor enhancements / bug fixes:
|
21
|
+
* Create tempfile using the basename without extension
|
22
|
+
(Edouard Chin #201)
|
23
|
+
* Save `session` during `follow_redirect!`
|
24
|
+
(Alexander Popov #218)
|
25
|
+
* Document how to use URL params with DELETE method
|
26
|
+
(Timur Platonov #220)
|
27
|
+
|
1
28
|
## 0.8.3 / 2018-02-27
|
2
29
|
|
3
30
|
* Bug fixes:
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Rack::Test
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/rack-test.svg)](https://badge.fury.io/rb/rack-test)
|
3
3
|
[<img src="https://travis-ci.org/rack-test/rack-test.svg?branch=master" />](https://travis-ci.org/rack-test/rack-test)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/
|
5
|
-
[![Test Coverage](https://codeclimate.com/github/
|
4
|
+
[![Code Climate](https://codeclimate.com/github/rack-test/rack-test/badges/gpa.svg)](https://codeclimate.com/github/rack-test/rack-test)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/rack-test/rack-test/badges/coverage.svg)](https://codeclimate.com/github/rack-test/rack-test/coverage)
|
6
6
|
|
7
7
|
Code: https://github.com/rack-test/rack-test
|
8
8
|
|
@@ -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'
|
117
|
+
gem 'rack-test'
|
110
118
|
```
|
111
119
|
|
112
120
|
Or to install unreleased version via Bundler:
|
@@ -136,5 +144,7 @@ Contributions are welcome. Please make sure to:
|
|
136
144
|
|
137
145
|
* Ensure `History.md` is up-to-date
|
138
146
|
* Bump VERSION in lib/rack/test/version.rb
|
147
|
+
* `git commit . -m 'Release 1.1.0'`
|
148
|
+
* `git push`
|
139
149
|
* bundle exec thor :release
|
140
150
|
* Updated the [GitHub releases page](https://github.com/rack-test/rack-test/releases)
|
data/lib/rack/test/cookie_jar.rb
CHANGED
@@ -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,
|
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))
|
data/lib/rack/test/version.rb
CHANGED
data/lib/rack/test.rb
CHANGED
@@ -188,11 +188,24 @@ 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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
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
|
+
|
198
|
+
# Compute the next location by appending the location header with the
|
199
|
+
# last request, as per https://tools.ietf.org/html/rfc7231#section-7.1.2
|
200
|
+
# Adding two absolute locations returns the right-hand location
|
201
|
+
next_location = URI.parse(last_request.url) + URI.parse(last_response['Location'])
|
202
|
+
|
203
|
+
send(
|
204
|
+
request_method, next_location.to_s, params,
|
205
|
+
'HTTP_REFERER' => last_request.url,
|
206
|
+
'rack.session' => last_request.session,
|
207
|
+
'rack.session.options' => last_request.session_options
|
208
|
+
)
|
196
209
|
end
|
197
210
|
|
198
211
|
private
|
@@ -227,7 +240,7 @@ module Rack
|
|
227
240
|
uri.query = [uri.query, build_nested_query(params)].compact.reject { |v| v == '' }.join('&')
|
228
241
|
end
|
229
242
|
elsif !env.key?(:input)
|
230
|
-
env['CONTENT_TYPE'] ||= 'application/x-www-form-urlencoded'
|
243
|
+
env['CONTENT_TYPE'] ||= 'application/x-www-form-urlencoded'
|
231
244
|
|
232
245
|
if params.is_a?(Hash)
|
233
246
|
if data = build_multipart(params)
|
@@ -235,6 +248,8 @@ module Rack
|
|
235
248
|
env['CONTENT_LENGTH'] ||= data.length.to_s
|
236
249
|
env['CONTENT_TYPE'] = "multipart/form-data; boundary=#{MULTIPART_BOUNDARY}"
|
237
250
|
else
|
251
|
+
# NB: We do not need to set CONTENT_LENGTH here;
|
252
|
+
# Rack::ContentLength will determine it automatically.
|
238
253
|
env[:input] = params_to_string(params)
|
239
254
|
end
|
240
255
|
else
|
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:
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -113,19 +113,19 @@ dependencies:
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0.50'
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
|
-
name:
|
116
|
+
name: simplecov
|
117
117
|
requirement: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
119
|
- - "~>"
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
version: '0.
|
121
|
+
version: '0.16'
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
124
|
version_requirements: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
126
|
- - "~>"
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
version: '0.
|
128
|
+
version: '0.16'
|
129
129
|
- !ruby/object:Gem::Dependency
|
130
130
|
name: thor
|
131
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
183
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.7.
|
184
|
+
rubygems_version: 2.7.7
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
187
|
summary: Simple testing API built on Rack
|