rack-test 0.6.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.md +375 -0
- data/MIT-LICENSE.txt +1 -0
- data/README.md +139 -0
- data/lib/rack/test/cookie_jar.rb +134 -64
- data/lib/rack/test/methods.rb +42 -31
- data/lib/rack/test/uploaded_file.rb +79 -19
- data/lib/rack/test/utils.rb +86 -80
- data/lib/rack/test/version.rb +5 -0
- data/lib/rack/test.rb +268 -204
- metadata +76 -68
- data/.document +0 -4
- data/.gitignore +0 -6
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -41
- data/History.txt +0 -179
- data/README.rdoc +0 -85
- data/Rakefile +0 -33
- data/Thorfile +0 -114
- data/lib/rack/mock_session.rb +0 -66
- data/lib/rack/test/mock_digest_request.rb +0 -29
- data/rack-test.gemspec +0 -77
- data/spec/fixtures/bar.txt +0 -1
- data/spec/fixtures/config.ru +0 -3
- data/spec/fixtures/fake_app.rb +0 -143
- data/spec/fixtures/foo.txt +0 -1
- data/spec/rack/test/cookie_spec.rb +0 -219
- data/spec/rack/test/digest_auth_spec.rb +0 -46
- data/spec/rack/test/multipart_spec.rb +0 -145
- data/spec/rack/test/uploaded_file_spec.rb +0 -24
- data/spec/rack/test/utils_spec.rb +0 -193
- data/spec/rack/test_spec.rb +0 -550
- data/spec/spec_helper.rb +0 -69
- data/spec/support/matchers/body.rb +0 -9
- data/spec/support/matchers/challenge.rb +0 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 98bb9656717c512790c5f65b20a8f0cfc7c2f14e4d9d98d5069e6e5910b256e5
|
4
|
+
data.tar.gz: 6305cac1636eef820a082a1431cef2bc24b445b1f902b65c550f976ba84f08e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 420e60a08ec2fa5fd92a358d28c0b17e0a943eb30962756360185091753bdd4eb55b7b58005aa84bb1907cfb7e8129166d1aed6282596f45b8b0f42dd1003306
|
7
|
+
data.tar.gz: b7446d71bf41a0f69b9812e867f7b472488ee0534d6206435b77e8266617486687044a814dd6c085003b823e0e349c83b1ca47ea296f1f23346957d66cbed0bc
|
data/History.md
ADDED
@@ -0,0 +1,375 @@
|
|
1
|
+
## 2.1.0 / 2023-03-14
|
2
|
+
|
3
|
+
* Breaking changes:
|
4
|
+
* Digest authentication support, deprecated in 2.0.0, has been
|
5
|
+
removed (Jeremy Evans #307)
|
6
|
+
* requiring rack/mock_session, deprecated in 2.0.0, has been removed
|
7
|
+
(Jeremy Evans #307)
|
8
|
+
|
9
|
+
* Minor enhancements:
|
10
|
+
* The `original_filename` for `Rack::Test::UploadedFile` can now be
|
11
|
+
set even if the content of the file comes from a file path
|
12
|
+
(Stuart Chinery #314)
|
13
|
+
* Add `Rack::Test::Session#restore_state`, for executing a block
|
14
|
+
and restoring current state (last request, last response, and
|
15
|
+
cookies) after the block (Jeremy Evans #316)
|
16
|
+
* Make `Rack::Test::Methods` support `default_host` method similar to
|
17
|
+
`app`, which will set the default host used for requests to the app
|
18
|
+
(Jeremy Evans #317 #318)
|
19
|
+
* Allow responses to set cookie paths not matching the current
|
20
|
+
request URI. Such cookies will only be sent for paths matching
|
21
|
+
the cookie path (Chris Waters #322)
|
22
|
+
* Ignore leading dot for cookie domains, per RFC 6265 (Stephen Crosby
|
23
|
+
#329)
|
24
|
+
* Avoid creating empty multipart body if params is empty in
|
25
|
+
`Rack::Test::Session#env_for` (Ryunosuke Sato #331)
|
26
|
+
|
27
|
+
## 2.0.2 / 2022-06-28
|
28
|
+
|
29
|
+
* Bug fixes:
|
30
|
+
* Fix additional incompatible character encodings error when building
|
31
|
+
uploaded bodies (Jeremy Evans #311)
|
32
|
+
|
33
|
+
## 2.0.1 / 2022-06-27
|
34
|
+
|
35
|
+
* Bug fixes:
|
36
|
+
* Fix incompatible character encodings error when building uploaded
|
37
|
+
file bodies (Jeremy Evans #308 #309)
|
38
|
+
|
39
|
+
## 2.0.0 / 2022-06-24
|
40
|
+
|
41
|
+
* Breaking changes:
|
42
|
+
* Digest authentication support is now deprecated, as it relies on
|
43
|
+
digest authentication support in rack, which has been deprecated
|
44
|
+
(Jeremy Evans #294)
|
45
|
+
* `Rack::Test::Utils.build_primitive_part` no longer handles array
|
46
|
+
values (Jeremy Evans #292)
|
47
|
+
* `Rack::Test::Utils` module methods other than `build_nested_query`
|
48
|
+
and `build_multipart` are now private methods (Jeremy Evans #297)
|
49
|
+
* `Rack::MockSession` has been combined into `Rack::Test::Session`,
|
50
|
+
and remains as an alias to `Rack::Test::Session`, but to keep some
|
51
|
+
backwards compatibility, `Rack::Test::Session.new` will accept a
|
52
|
+
`Rack::Test::Session` instance and return it (Jeremy Evans #297)
|
53
|
+
* Previously protected methods in `Rack::Test::Cookie{,Jar}` are now
|
54
|
+
private methods (Jeremy Evans #297)
|
55
|
+
* `Rack::Test::Methods` no longer defines `build_rack_mock_session`,
|
56
|
+
but for backwards compatibility, `build_rack_test_session` will call
|
57
|
+
`build_rack_mock_session` if it is defined (Jeremy Evans #297)
|
58
|
+
* `Rack::Test::Methods::METHODS` is no longer defined
|
59
|
+
(Jeremy Evans #297)
|
60
|
+
* `Rack::Test::Methods#_current_session_names` has been removed
|
61
|
+
(Jeremy Evans #297)
|
62
|
+
* Headers used/accessed by rack-test are now lower case, for rack 3
|
63
|
+
compliance (Jeremy Evans #295)
|
64
|
+
* Frozen literal strings are now used internally, which may break
|
65
|
+
code that mutates static strings returned by rack-test, if any
|
66
|
+
(Jeremy Evans #304)
|
67
|
+
|
68
|
+
* Minor enhancements:
|
69
|
+
* rack-test now works with the rack main branch (what will be rack 3)
|
70
|
+
(Jeremy Evans #280 #292)
|
71
|
+
* rack-test only loads the parts of rack it uses when running on the
|
72
|
+
rack main branch (what will be rack 3) (Jeremy Evans #292)
|
73
|
+
* Development dependencies have been significantly reduced, and are
|
74
|
+
now a subset of the development dependencies of rack itself
|
75
|
+
(Jeremy Evans #292)
|
76
|
+
* Avoid creating multiple large copies of uploaded file data in
|
77
|
+
memory (Jeremy Evans #286)
|
78
|
+
* Specify HTTP/1.0 when submitting requests, to avoid responses with
|
79
|
+
Transfer-Encoding: chunked (Jeremy Evans #288)
|
80
|
+
* Support `:query_params` in rack environment for parameters that
|
81
|
+
are appended to the query string instead of used in the request
|
82
|
+
body (Jeremy Evans #150 #287)
|
83
|
+
* Reduce required ruby version to 2.0, since tests run fine on
|
84
|
+
Ruby 2.0 (Jeremy Evans #292)
|
85
|
+
* Support :multipart env key for request methods to force multipart
|
86
|
+
input (Jeremy Evans #303)
|
87
|
+
* Force multipart input for request methods if content type starts
|
88
|
+
with multipart (Jeremy Evans #303)
|
89
|
+
* Improve performance of Utils.build_multipart by using an
|
90
|
+
append-only design (Jeremy Evans #304)
|
91
|
+
* Improve performance of Utils.build_nested_query for array values
|
92
|
+
(Jeremy Evans #304)
|
93
|
+
|
94
|
+
* Bug fixes:
|
95
|
+
* The `CONTENT_TYPE` of multipart requests is now respected, if it
|
96
|
+
starts with `multipart/` (Tom Knig #238)
|
97
|
+
* Work correctly with responses that respond to `to_a` but not
|
98
|
+
`to_ary` (Sergio Faria #276)
|
99
|
+
* Raise an ArgumentError instead of a TypeError when providing a
|
100
|
+
StringIO without an original filename when creating an
|
101
|
+
UploadedFile (Nuno Correia #279)
|
102
|
+
* Allow combining both an UploadedFile and a plain string when
|
103
|
+
building a multipart upload (Mitsuhiro Shibuya #278)
|
104
|
+
* Fix the generation of filenames with spaces to use path
|
105
|
+
escaping instead of regular escaping, since path unescaping is
|
106
|
+
used to decode it (Muir Manders, Jeremy Evans #275 #284)
|
107
|
+
* Rewind tempfile used for multipart uploads before it is
|
108
|
+
submitted to the application
|
109
|
+
(Jeremy Evans, Alexander Dervish #261 #268 #286)
|
110
|
+
* Fix Rack::Test.encoding_aware_strings to be true only on rack
|
111
|
+
1.6+ (Jeremy Evans #292)
|
112
|
+
* Make Rack::Test::CookieJar#valid? return true/false
|
113
|
+
(Jeremy Evans #292)
|
114
|
+
* Cookies without a domain attribute no longer are submitted to
|
115
|
+
requests for subdomains of that domain, for RFC 6265
|
116
|
+
compliance (Jeremy Evans #292)
|
117
|
+
* Increase required rack version to 1.3, since tests fail on
|
118
|
+
rack 1.2 and below (Jeremy Evans #293)
|
119
|
+
|
120
|
+
## 1.1.0 / 2018-07-21
|
121
|
+
|
122
|
+
* Breaking changes:
|
123
|
+
* None
|
124
|
+
|
125
|
+
* Minor enhancements / new functionality:
|
126
|
+
* [GitHub] Added configuration for Stale (Per Lundberg #232)
|
127
|
+
* follow_direct: Include rack.session.options (Mark Edmondson #233)
|
128
|
+
* [CI] Add simplecov (fatkodima #227)
|
129
|
+
|
130
|
+
* Bug fixes:
|
131
|
+
* Follow relative locations correctly. (Samuel Williams #230)
|
132
|
+
|
133
|
+
## 1.0.0 / 2018-03-27
|
134
|
+
|
135
|
+
* Breaking changes:
|
136
|
+
* Always set CONTENT_TYPE for non-GET requests
|
137
|
+
(Per Lundberg #223)
|
138
|
+
|
139
|
+
* Minor enhancements / bug fixes:
|
140
|
+
* Create tempfile using the basename without extension
|
141
|
+
(Edouard Chin #201)
|
142
|
+
* Save `session` during `follow_redirect!`
|
143
|
+
(Alexander Popov #218)
|
144
|
+
* Document how to use URL params with DELETE method
|
145
|
+
(Timur Platonov #220)
|
146
|
+
|
147
|
+
## 0.8.3 / 2018-02-27
|
148
|
+
|
149
|
+
* Bug fixes:
|
150
|
+
* Do not set Content-Type if params are explicitly set to nil
|
151
|
+
(Bartek Bułat #212). Fixes #200.
|
152
|
+
* Fix `UploadedFile#new` regression
|
153
|
+
(Per Lundberg #215)
|
154
|
+
|
155
|
+
* Minor enhancements
|
156
|
+
* [CI] Test against Ruby 2.5 (Nicolas Leger #217)
|
157
|
+
|
158
|
+
## 0.8.2 / 2017-11-21
|
159
|
+
|
160
|
+
* Bug fixes:
|
161
|
+
* Bugfix for `UploadedFile.new` unintended API breakage.
|
162
|
+
(Per Lundberg #210)
|
163
|
+
|
164
|
+
## 0.8.0 / 2017-11-20
|
165
|
+
|
166
|
+
* Known Issue
|
167
|
+
* In `UploadedFile.new`, when passing e.g. a `Pathname` object,
|
168
|
+
errors can be raised (eg. `ArgumentError: Missing original_filename
|
169
|
+
for IO`, or `NoMethodError: undefined method 'size'`) See #207, #209.
|
170
|
+
* Minor enhancements
|
171
|
+
* Add a required_ruby_version of >= 2.2.2, similar to rack 2.0.1.
|
172
|
+
(Samuel Giddins #194)
|
173
|
+
* Remove new line from basic auth. (Felix Kleinschmidt #185)
|
174
|
+
* Rubocop fixes (Per Lundberg #196)
|
175
|
+
* Add how to install rack-test from github to README. (Jun Aruga #189)
|
176
|
+
* Update CodeClimate badges (Toshimaru #195)
|
177
|
+
* Add the ability to create Test::UploadedFile instances without
|
178
|
+
the file system (Adam Milligan #149)
|
179
|
+
* Add custom_request, remove duplication (Johannes Barre #184)
|
180
|
+
* README.md: Added note about how to post JSON (Per Lundberg #198)
|
181
|
+
* README.md: Added version badge (Per Lundberg #199)
|
182
|
+
* Bug fixes
|
183
|
+
* Bugfix for Cookies with multiple paths (Kyle Welsby #197)
|
184
|
+
|
185
|
+
## 0.7.0 / 2017-07-10
|
186
|
+
|
187
|
+
* Major enhancements
|
188
|
+
* The project URL changed to https://github.com/rack-test/rack-test
|
189
|
+
(Per Lundberg, Dennis Sivia, Jun Aruga)
|
190
|
+
* Rack 2 compatible. (Trevor Wennblom #81, Vít Ondruch, Jun Aruga #151)
|
191
|
+
* Minor enhancements
|
192
|
+
* Port to RSpec 3. (Murahashi [Matt] Kenichi #70, Antonio Terceiro #134)
|
193
|
+
* Add Travis CI (Johannes Barre #108, Jun Aruga #161)
|
194
|
+
* Don't append an ampersand when params are empty (sbilharz, #157)
|
195
|
+
* Allow symbol access to cookies (Anorlondo448 #156)
|
196
|
+
* README: Added Travis badge (Olivier Lacan, Per Lundberg #146)
|
197
|
+
* `Rack::Test::Utils#build_multipart`: Allow passing a third parameter
|
198
|
+
to force multipart (Koen Punt #142)
|
199
|
+
* Allow better testing of cookies (Stephen Best #133)
|
200
|
+
* make `build_multipart` work without mixing in `Rack::Test::Utils`
|
201
|
+
(Aaron Patterson #131)
|
202
|
+
* Add license to gemspec (Jordi Massaguer Pla #72, Anatol Pomozov #89,
|
203
|
+
Anatol Pomozov #90, Johannes Barre #109, Mandaryn #115,
|
204
|
+
Chris Marshall #120, Robert Reiz #126, Nic Benders #127, Nic Benders #130)
|
205
|
+
* Feature/bulk pr for readme updates (Patrick Mulder #65,
|
206
|
+
Troels Knak-Nielsen #74, Jeff Casimir #76)
|
207
|
+
* Switch README format to Markdown (Dennis Sivia #176)
|
208
|
+
* Convert History.txt to Markdown (Dennis Sivia #179)
|
209
|
+
* Stop generating gemspec file. (Jun Aruga #181)
|
210
|
+
* Fix errors at rake docs and whitespace. (Jun Aruga #183)
|
211
|
+
* Ensure Rack::Test::UploadedFile closes its tempfile file descriptor
|
212
|
+
on GC (Michael de Silva #180)
|
213
|
+
* Change codeclimate URL correctly. (Jun Aruga #186)
|
214
|
+
* Bug fixes
|
215
|
+
* Initialize digest_username before using it. (Guo Xiang Tan #116,
|
216
|
+
John Drago #124, Mike Perham #154)
|
217
|
+
* Do not set Content-Type for DELETE requests (David Celis #132)
|
218
|
+
* Adds support for empty arrays in params. (Cedric Röck, Tim Masliuchenko
|
219
|
+
#125)
|
220
|
+
* Update README code example quotes to be consistent. (Dmitry Gritsay #112)
|
221
|
+
* Update README not to recommend installing gem with sudo. (T.J. Schuck #87)
|
222
|
+
* Set scheme when using ENV to enable SSL (Neil Ang #155)
|
223
|
+
* Reuse request method and parameters on HTTP 307 redirect. (Martin Mauch
|
224
|
+
#138)
|
225
|
+
|
226
|
+
## 0.6.3 / 2015-01-09
|
227
|
+
|
228
|
+
* Minor enhancements
|
229
|
+
* Expose an env helper for persistently configuring the env as needed
|
230
|
+
(Darío Javier Cravero #80)
|
231
|
+
* Expose the tempfile of UploadedFile (Sytse Sijbrandij #67)
|
232
|
+
* Bug fixes
|
233
|
+
* Improve support for arrays of hashes in multipart forms (Murray Steele #69)
|
234
|
+
* Improve test for query strings (Paul Grayson #66)
|
235
|
+
|
236
|
+
## 0.6.2 / 2012-09-27
|
237
|
+
|
238
|
+
* Minor enhancements
|
239
|
+
* Support HTTP PATCH method (Marjan Krekoten' #33)
|
240
|
+
* Preserve the exact query string when possible (Paul Grayson #63)
|
241
|
+
* Add a #delete method to CookieJar (Paul Grayson #63)
|
242
|
+
* Bug fixes
|
243
|
+
* Fix HTTP Digest authentication when the URI has query params
|
244
|
+
* Don't append default ports to HTTP_HOST (David Lee #57)
|
245
|
+
|
246
|
+
## 0.6.1 / 2011-07-27
|
247
|
+
|
248
|
+
* Bug fixes
|
249
|
+
* Fix support for params with arrays in multipart forms (Joel Chippindale)
|
250
|
+
* Add `respond_to?` to `Rack::Test::UploadedFile` to match `method_missing` (Josh Nichols)
|
251
|
+
* Set the Referer header on requests issued by follow_redirect! (Ryan Bigg)
|
252
|
+
|
253
|
+
## 0.6.0 / 2011-05-03
|
254
|
+
|
255
|
+
* Bug fixes
|
256
|
+
* Add support for HTTP OPTIONS verb (Paolo "Nusco" Perrotta)
|
257
|
+
* Call #finish on MockResponses if it's available (Aaron Patterson)
|
258
|
+
* Allow HTTP_HOST to be set via #header (Geoff Buesing)
|
259
|
+
|
260
|
+
## 0.5.7 / 2011-01-01
|
261
|
+
* Bug fixes
|
262
|
+
* If no URI is present, include all cookies (Pratik Naik)
|
263
|
+
|
264
|
+
## 0.5.6 / 2010-09-25
|
265
|
+
|
266
|
+
* Bug fixes
|
267
|
+
* Use parse_nested_query for parsing URI like Rack does (Eugene Bolshakov)
|
268
|
+
* Don't depend on ActiveSupport extension to String (Bryan Helmkamp)
|
269
|
+
* Do not overwrite HTTP_HOST if it is set (Krekoten' Marjan)
|
270
|
+
|
271
|
+
## 0.5.5 / 2010-09-22
|
272
|
+
|
273
|
+
* Bug fixes
|
274
|
+
* Fix encoding of file uploads on Ruby 1.9 (Alan Kennedy)
|
275
|
+
* Set env["HTTP_HOST"] when making requests (Istvan Hoka)
|
276
|
+
|
277
|
+
## 0.5.4 / 2010-05-26
|
278
|
+
|
279
|
+
* Bug fixes
|
280
|
+
* Don't stomp on Content-Type's supplied via #header (Bryan Helmkamp)
|
281
|
+
* Fixed build_multipart to allow for arrays of files (Louis Rose)
|
282
|
+
* Don't raise an error if raw cookies contain a blank line (John Reilly)
|
283
|
+
* Handle parameter names with brackets properly (Tanner Donovan)
|
284
|
+
|
285
|
+
## 0.5.3 / 2009-11-27
|
286
|
+
|
287
|
+
* Bug fixes
|
288
|
+
* Fix cookie matching for subdomains (Marcin Kulik)
|
289
|
+
|
290
|
+
## 0.5.2 / 2009-11-13
|
291
|
+
|
292
|
+
* Bug fixes
|
293
|
+
* Call close on response body after iteration, not before (Simon Rozet)
|
294
|
+
* Add missing require for time in cookie_jar.rb (Jerry West)
|
295
|
+
|
296
|
+
## 0.5.1 / 2009-10-27
|
297
|
+
|
298
|
+
* Bug fixes
|
299
|
+
* Escape cookie values (John Pignata)
|
300
|
+
* Close the response body after each request, as per the Rack spec (Elomar França)
|
301
|
+
|
302
|
+
## 0.5.0 / 2009-09-19
|
303
|
+
|
304
|
+
* Bug fixes
|
305
|
+
* Set HTTP_X_REQUESTED_WITH in the Rack env when a request is made with :xhr => true (Ben Sales)
|
306
|
+
* Set headers in the Rack env in HTTP_USER_AGENT form
|
307
|
+
* Rack::Test now generates no Ruby warnings
|
308
|
+
|
309
|
+
## 0.4.2 / 2009-09-01
|
310
|
+
|
311
|
+
* Minor enhancements
|
312
|
+
* Merge in rack/master's build_multipart method which covers additional cases
|
313
|
+
* Accept raw :params string input and merge it with the query string
|
314
|
+
* Stringify and upcase request method (e.g. :post => "POST") (Josh Peek)
|
315
|
+
* Bug fixes
|
316
|
+
* Properly convert hashes with nil values (e.g. :foo => nil becomes simply "foo", not "foo=")
|
317
|
+
* Prepend a slash to the URI path if it doesn't start with one (Josh Peek)
|
318
|
+
* Requiring Rack-Test never modifies the Ruby load path anymore (Josh Peek)
|
319
|
+
* Fixed using multiple cookies in a string on Ruby 1.8 (Tuomas Kareinen and Hermanni Hyytiälä)
|
320
|
+
|
321
|
+
## 0.4.1 / 2009-08-06
|
322
|
+
|
323
|
+
* Minor enhancements
|
324
|
+
* Support initializing a `Rack::Test::Session` with an app in addition to
|
325
|
+
a `Rack::MockSession`
|
326
|
+
* Allow CONTENT_TYPE to be specified in the env and not overwritten when
|
327
|
+
sending a POST or PUT
|
328
|
+
|
329
|
+
## 0.4.0 / 2009-06-25
|
330
|
+
|
331
|
+
* Minor enhancements
|
332
|
+
* Expose hook for building `Rack::MockSessions` for frameworks that need
|
333
|
+
to configure them before use
|
334
|
+
* Support passing in arrays of raw cookies in addition to a newline
|
335
|
+
separated string
|
336
|
+
* Support after_request callbacks in MockSession for things like running
|
337
|
+
background jobs
|
338
|
+
* Allow multiple named sessions using with_session
|
339
|
+
* Initialize `Rack::Test::Sessions` with `Rack::MockSessions` instead of apps.
|
340
|
+
This change should help integration with other Ruby web frameworks
|
341
|
+
(like Merb).
|
342
|
+
* Support sending bodies for PUT requests (Larry Diehl)
|
343
|
+
|
344
|
+
## 0.3.0 / 2009-05-17
|
345
|
+
|
346
|
+
* Major enhancements
|
347
|
+
* Ruby 1.9 compatible (Simon Rozet, Michael Fellinger)
|
348
|
+
* Minor enhancements
|
349
|
+
* Add `CookieJar#[]` and `CookieJar#[]=` methods
|
350
|
+
* Make the default host configurable
|
351
|
+
* Use `Rack::Lint` and fix errors (Simon Rozet)
|
352
|
+
* Extract `Rack::MockSession` from `Rack::Test::Session` to handle tracking
|
353
|
+
the last request and response and the cookie jar
|
354
|
+
* Add #set_cookie and #clear_cookies methods
|
355
|
+
* Rename #authorize to #basic_authorize (#authorize remains as an alias)
|
356
|
+
(Simon Rozet)
|
357
|
+
|
358
|
+
## 0.2.0 / 2009-04-26
|
359
|
+
|
360
|
+
Because `#last_response` is now a `MockResponse` instead of a `Rack::Response`, `#last_response.body`
|
361
|
+
now returns a string instead of an array.
|
362
|
+
|
363
|
+
* Major enhancements
|
364
|
+
* Support multipart requests via the UploadedFile class (thanks, Rails)
|
365
|
+
* Minor enhancements
|
366
|
+
* Updated for Rack 1.0
|
367
|
+
* Don't require rubygems (See http://gist.github.com/54177)
|
368
|
+
* Support HTTP Digest authentication with the `#digest_authorize` method
|
369
|
+
* `#last_response` returns a `MockResponse` instead of a Response
|
370
|
+
(Michael Fellinger)
|
371
|
+
|
372
|
+
## 0.1.0 / 2009-03-02
|
373
|
+
|
374
|
+
* 1 major enhancement
|
375
|
+
* Birthday!
|
data/MIT-LICENSE.txt
CHANGED
data/README.md
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
# Rack::Test
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/rack-test.svg)](https://badge.fury.io/rb/rack-test)
|
3
|
+
|
4
|
+
Code: https://github.com/rack/rack-test
|
5
|
+
|
6
|
+
## Description
|
7
|
+
|
8
|
+
Rack::Test is a small, simple testing API for Rack apps. It can be used on its
|
9
|
+
own or as a reusable starting point for Web frameworks and testing libraries
|
10
|
+
to build on.
|
11
|
+
|
12
|
+
## Features
|
13
|
+
|
14
|
+
* Allows for submitting requests and testing responses
|
15
|
+
* Maintains a cookie jar across requests
|
16
|
+
* Supports request headers used for subsequent requests
|
17
|
+
* Follow redirects when requested
|
18
|
+
|
19
|
+
## Examples
|
20
|
+
|
21
|
+
These examples use `test/unit` but it's equally possible to use `rack-test` with
|
22
|
+
other testing frameworks such as `minitest` or `rspec`.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require "test/unit"
|
26
|
+
require "rack/test"
|
27
|
+
require "json"
|
28
|
+
|
29
|
+
class HomepageTest < Test::Unit::TestCase
|
30
|
+
include Rack::Test::Methods
|
31
|
+
|
32
|
+
def app
|
33
|
+
lambda { |env| [200, {'content-type' => 'text/plain'}, ['All responses are OK']] }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_response_is_ok
|
37
|
+
# Optionally set headers used for all requests in this spec:
|
38
|
+
#header 'accept-charset', 'utf-8'
|
39
|
+
|
40
|
+
# First argument is treated as the path
|
41
|
+
get '/'
|
42
|
+
|
43
|
+
assert last_response.ok?
|
44
|
+
assert_equal 'All responses are OK', last_response.body
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete_with_url_params_and_body
|
48
|
+
# First argument can have a query string
|
49
|
+
#
|
50
|
+
# Second argument is used as the parameters for the request, which will be
|
51
|
+
# included in the request body for non-GET requests.
|
52
|
+
delete '/?foo=bar', JSON.generate('baz' => 'zot')
|
53
|
+
end
|
54
|
+
|
55
|
+
def post_with_json
|
56
|
+
# Third argument is the rack environment to use for the request. The following
|
57
|
+
# entries in the submitted rack environment are treated specially (in addition
|
58
|
+
# to options supported by `Rack::MockRequest#env_for`:
|
59
|
+
#
|
60
|
+
# :cookie : Set a cookie for the current session before submitting the request.
|
61
|
+
#
|
62
|
+
# :query_params : Set parameters for the query string (as opposed to the body).
|
63
|
+
# Value should be a hash of parameters.
|
64
|
+
#
|
65
|
+
# :xhr : Set HTTP_X_REQUESTED_WITH env key to XMLHttpRequest.
|
66
|
+
post(uri, JSON.generate('baz' => 'zot'), 'CONTENT_TYPE' => 'application/json')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
`rack-test` will test the app returned by the `app` method. If you are loading middleware
|
72
|
+
in a `config.ru` file, and want to test that, you should load the Rack app created from
|
73
|
+
the `config.ru` file:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
OUTER_APP = Rack::Builder.parse_file("config.ru").first
|
77
|
+
|
78
|
+
class TestApp < Test::Unit::TestCase
|
79
|
+
include Rack::Test::Methods
|
80
|
+
|
81
|
+
def app
|
82
|
+
OUTER_APP
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_root
|
86
|
+
get "/"
|
87
|
+
assert last_response.ok?
|
88
|
+
end
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
## Install
|
93
|
+
|
94
|
+
To install the latest release as a gem:
|
95
|
+
|
96
|
+
```
|
97
|
+
gem install rack-test
|
98
|
+
```
|
99
|
+
|
100
|
+
Or add to your `Gemfile`:
|
101
|
+
|
102
|
+
```
|
103
|
+
gem 'rack-test'
|
104
|
+
```
|
105
|
+
|
106
|
+
## Contribution
|
107
|
+
|
108
|
+
Contributions are welcome. Please make sure to:
|
109
|
+
|
110
|
+
* Use a regular forking workflow
|
111
|
+
* Write tests for the new or changed behaviour
|
112
|
+
* Provide an explanation/motivation in your commit message / PR message
|
113
|
+
* Ensure `History.md` is updated
|
114
|
+
|
115
|
+
## Authors
|
116
|
+
|
117
|
+
- Contributions from Bryan Helmkamp, Jeremy Evans, Simon Rozet, and others
|
118
|
+
- Much of the original code was extracted from Merb 1.0's request helper
|
119
|
+
|
120
|
+
## License
|
121
|
+
|
122
|
+
`rack-test` is released under the [MIT License](MIT-LICENSE.txt).
|
123
|
+
|
124
|
+
## Supported platforms
|
125
|
+
|
126
|
+
* Ruby 2.0+
|
127
|
+
* JRuby 9.1+
|
128
|
+
|
129
|
+
## Releasing
|
130
|
+
|
131
|
+
* Bump VERSION in lib/rack/test/version.rb
|
132
|
+
* Ensure `History.md` is up-to-date, including correct version and date
|
133
|
+
* `git commit . -m 'Release $VERSION'`
|
134
|
+
* `git push`
|
135
|
+
* `git tag -a -m 'Tag the $VERSION release' $VERSION`
|
136
|
+
* `git push --tags`
|
137
|
+
* `gem build rack-test.gemspec`
|
138
|
+
* `gem push rack-test-$VERSION.gem`
|
139
|
+
* Add a discussion post for the release
|