rack-test 0.6.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{History.txt → History.md} +87 -58
- data/README.md +139 -0
- data/lib/rack/mock_session.rb +6 -9
- data/lib/rack/test/cookie_jar.rb +38 -28
- data/lib/rack/test/methods.rb +22 -22
- data/lib/rack/test/mock_digest_request.rb +1 -5
- data/lib/rack/test/uploaded_file.rb +41 -19
- data/lib/rack/test/utils.rb +37 -43
- data/lib/rack/test/version.rb +5 -0
- data/lib/rack/test.rb +79 -78
- metadata +139 -60
- data/.document +0 -4
- data/.gitignore +0 -6
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -41
- data/README.rdoc +0 -85
- data/Rakefile +0 -33
- data/Thorfile +0 -114
- 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
|
+
SHA1:
|
3
|
+
metadata.gz: 1c2c9dca5557f9f1d5894f9379e38e660698a178
|
4
|
+
data.tar.gz: aabbb52783cc359935090e319d462076cc0ce95c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ed423ebaf4bbdb79a77804f3ed9314f88b5b9e97e9a0eeee0d596c43718bac918f62d4cfd8c1adaa72a0e8fce28f093f5bb7bc3268eec5025c6e47b7ce2556b9
|
7
|
+
data.tar.gz: a4ef34a8cb3e12bc432012444485af04c50c2780ec658ead424c337dbd3ecd3805a957065bb804b2b1dd73d495819094dfb018c0784cd9766a4f1be6110d7815
|
data/{History.txt → History.md}
RENAMED
@@ -1,179 +1,208 @@
|
|
1
|
-
|
1
|
+
## 0.8.0 / 2017-11-20
|
2
2
|
|
3
3
|
* Minor enhancements
|
4
|
+
* Add a required_ruby_version of >= 2.2.2, similar to rack 2.0.1.
|
5
|
+
(Samuel Giddins #194)
|
6
|
+
* Remove new line from basic auth. (Felix Kleinschmidt #185)
|
7
|
+
* Rubocop fixes (Per Lundberg #196)
|
8
|
+
* Add how to install rack-test from github to README. (Jun Aruga #189)
|
9
|
+
* Update CodeClimate badges (Toshimaru #195)
|
10
|
+
* Add the ability to create Test::UploadedFile instances without
|
11
|
+
the file system (Adam Milligan #149)
|
12
|
+
* Add custom_request, remove duplication (Johannes Barre #184)
|
13
|
+
* README.md: Added note about how to post JSON (Per Lundberg #198)
|
14
|
+
* README.md: Added version badge (Per Lundberg #199)
|
15
|
+
* Bug fixes
|
16
|
+
* Bugfix for Cookies with multiple paths (Kyle Welsby #197)
|
17
|
+
|
18
|
+
## 0.7.0 / 2017-07-10
|
4
19
|
|
20
|
+
* Major enhancements
|
21
|
+
* The project URL changed to https://github.com/rack-test/rack-test
|
22
|
+
(Per Lundberg, Dennis Sivia, Jun Aruga)
|
23
|
+
* Rack 2 compatible. (Trevor Wennblom #81, Vít Ondruch, Jun Aruga #151)
|
24
|
+
* Minor enhancements
|
25
|
+
* Port to RSpec 3. (Murahashi [Matt] Kenichi #70, Antonio Terceiro #134)
|
26
|
+
* Add Travis CI (Johannes Barre #108, Jun Aruga #161)
|
27
|
+
* Don't append an ampersand when params are empty (sbilharz, #157)
|
28
|
+
* Allow symbol access to cookies (Anorlondo448 #156)
|
29
|
+
* README: Added Travis badge (Olivier Lacan, Per Lundberg #146)
|
30
|
+
* `Rack::Test::Utils#build_multipart`: Allow passing a third parameter
|
31
|
+
to force multipart (Koen Punt #142)
|
32
|
+
* Allow better testing of cookies (Stephen Best #133)
|
33
|
+
* make `build_multipart` work without mixing in `Rack::Test::Utils`
|
34
|
+
(Aaron Patterson #131)
|
35
|
+
* Add license to gemspec (Jordi Massaguer Pla #72, Anatol Pomozov #89,
|
36
|
+
Anatol Pomozov #90, Johannes Barre #109, Mandaryn #115,
|
37
|
+
Chris Marshall #120, Robert Reiz #126, Nic Benders #127, Nic Benders #130)
|
38
|
+
* Feature/bulk pr for readme updates (Patrick Mulder #65,
|
39
|
+
Troels Knak-Nielsen #74, Jeff Casimir #76)
|
40
|
+
* Switch README format to Markdown (Dennis Sivia #176)
|
41
|
+
* Convert History.txt to Markdown (Dennis Sivia #179)
|
42
|
+
* Stop generating gemspec file. (Jun Aruga #181)
|
43
|
+
* Fix errors at rake docs and whitespace. (Jun Aruga #183)
|
44
|
+
* Ensure Rack::Test::UploadedFile closes its tempfile file descriptor
|
45
|
+
on GC (Michael de Silva #180)
|
46
|
+
* Change codeclimate URL correctly. (Jun Aruga #186)
|
47
|
+
* Bug fixes
|
48
|
+
* Initialize digest_username before using it. (Guo Xiang Tan #116,
|
49
|
+
John Drago #124, Mike Perham #154)
|
50
|
+
* Do not set Content-Type for DELETE requests (David Celis #132)
|
51
|
+
* Adds support for empty arrays in params. (Cedric Röck, Tim Masliuchenko
|
52
|
+
#125)
|
53
|
+
* Update README code example quotes to be consistent. (Dmitry Gritsay #112)
|
54
|
+
* Update README not to recommend installing gem with sudo. (T.J. Schuck #87)
|
55
|
+
* Set scheme when using ENV to enable SSL (Neil Ang #155)
|
56
|
+
* Reuse request method and parameters on HTTP 307 redirect. (Martin Mauch
|
57
|
+
#138)
|
58
|
+
|
59
|
+
## 0.6.3 / 2015-01-09
|
60
|
+
|
61
|
+
* Minor enhancements
|
5
62
|
* Expose an env helper for persistently configuring the env as needed
|
6
63
|
(Darío Javier Cravero #80)
|
7
64
|
* Expose the tempfile of UploadedFile (Sytse Sijbrandij #67)
|
8
|
-
|
9
65
|
* Bug fixes
|
10
|
-
|
11
66
|
* Improve support for arrays of hashes in multipart forms (Murray Steele #69)
|
12
67
|
* Improve test for query strings (Paul Grayson #66)
|
13
68
|
|
14
|
-
|
69
|
+
## 0.6.2 / 2012-09-27
|
15
70
|
|
16
71
|
* Minor enhancements
|
17
|
-
|
18
72
|
* Support HTTP PATCH method (Marjan Krekoten' #33)
|
19
73
|
* Preserve the exact query string when possible (Paul Grayson #63)
|
20
74
|
* Add a #delete method to CookieJar (Paul Grayson #63)
|
21
|
-
|
22
75
|
* Bug fixes
|
23
|
-
|
24
76
|
* Fix HTTP Digest authentication when the URI has query params
|
25
77
|
* Don't append default ports to HTTP_HOST (David Lee #57)
|
26
78
|
|
27
|
-
|
79
|
+
## 0.6.1 / 2011-07-27
|
28
80
|
|
29
81
|
* Bug fixes
|
30
|
-
|
31
82
|
* Fix support for params with arrays in multipart forms (Joel Chippindale)
|
32
|
-
* Add respond_to
|
83
|
+
* Add `respond_to?` to `Rack::Test::UploadedFile` to match `method_missing` (Josh Nichols)
|
33
84
|
* Set the Referer header on requests issued by follow_redirect! (Ryan Bigg)
|
34
85
|
|
35
|
-
|
86
|
+
## 0.6.0 / 2011-05-03
|
36
87
|
|
37
88
|
* Bug fixes
|
38
|
-
|
39
89
|
* Add support for HTTP OPTIONS verb (Paolo "Nusco" Perrotta)
|
40
90
|
* Call #finish on MockResponses if it's available (Aaron Patterson)
|
41
91
|
* Allow HTTP_HOST to be set via #header (Geoff Buesing)
|
42
92
|
|
43
|
-
|
44
|
-
|
93
|
+
## 0.5.7 / 2011-01-01
|
45
94
|
* Bug fixes
|
46
|
-
|
47
95
|
* If no URI is present, include all cookies (Pratik Naik)
|
48
96
|
|
49
|
-
|
97
|
+
## 0.5.6 / 2010-09-25
|
50
98
|
|
51
99
|
* Bug fixes
|
52
|
-
|
53
100
|
* Use parse_nested_query for parsing URI like Rack does (Eugene Bolshakov)
|
54
101
|
* Don't depend on ActiveSupport extension to String (Bryan Helmkamp)
|
55
102
|
* Do not overwrite HTTP_HOST if it is set (Krekoten' Marjan)
|
56
103
|
|
57
|
-
|
104
|
+
## 0.5.5 / 2010-09-22
|
58
105
|
|
59
106
|
* Bug fixes
|
60
|
-
|
61
107
|
* Fix encoding of file uploads on Ruby 1.9 (Alan Kennedy)
|
62
108
|
* Set env["HTTP_HOST"] when making requests (Istvan Hoka)
|
63
109
|
|
64
|
-
|
110
|
+
## 0.5.4 / 2010-05-26
|
65
111
|
|
66
112
|
* Bug fixes
|
67
|
-
|
68
113
|
* Don't stomp on Content-Type's supplied via #header (Bryan Helmkamp)
|
69
114
|
* Fixed build_multipart to allow for arrays of files (Louis Rose)
|
70
115
|
* Don't raise an error if raw cookies contain a blank line (John Reilly)
|
71
116
|
* Handle parameter names with brackets properly (Tanner Donovan)
|
72
117
|
|
73
|
-
|
118
|
+
## 0.5.3 / 2009-11-27
|
74
119
|
|
75
120
|
* Bug fixes
|
76
|
-
|
77
121
|
* Fix cookie matching for subdomains (Marcin Kulik)
|
78
122
|
|
79
|
-
|
123
|
+
## 0.5.2 / 2009-11-13
|
80
124
|
|
81
125
|
* Bug fixes
|
82
|
-
|
83
126
|
* Call close on response body after iteration, not before (Simon Rozet)
|
84
127
|
* Add missing require for time in cookie_jar.rb (Jerry West)
|
85
128
|
|
86
|
-
|
129
|
+
## 0.5.1 / 2009-10-27
|
87
130
|
|
88
131
|
* Bug fixes
|
89
|
-
|
90
132
|
* Escape cookie values (John Pignata)
|
91
133
|
* Close the response body after each request, as per the Rack spec (Elomar França)
|
92
134
|
|
93
|
-
|
135
|
+
## 0.5.0 / 2009-09-19
|
94
136
|
|
95
137
|
* Bug fixes
|
96
|
-
|
97
138
|
* Set HTTP_X_REQUESTED_WITH in the Rack env when a request is made with :xhr => true (Ben Sales)
|
98
139
|
* Set headers in the Rack env in HTTP_USER_AGENT form
|
99
140
|
* Rack::Test now generates no Ruby warnings
|
100
141
|
|
101
|
-
|
142
|
+
## 0.4.2 / 2009-09-01
|
102
143
|
|
103
144
|
* Minor enhancements
|
104
|
-
|
105
145
|
* Merge in rack/master's build_multipart method which covers additional cases
|
106
146
|
* Accept raw :params string input and merge it with the query string
|
107
147
|
* Stringify and upcase request method (e.g. :post => "POST") (Josh Peek)
|
108
|
-
|
109
148
|
* Bug fixes
|
110
|
-
|
111
149
|
* Properly convert hashes with nil values (e.g. :foo => nil becomes simply "foo", not "foo=")
|
112
150
|
* Prepend a slash to the URI path if it doesn't start with one (Josh Peek)
|
113
151
|
* Requiring Rack-Test never modifies the Ruby load path anymore (Josh Peek)
|
114
152
|
* Fixed using multiple cookies in a string on Ruby 1.8 (Tuomas Kareinen and Hermanni Hyytiälä)
|
115
153
|
|
116
|
-
|
154
|
+
## 0.4.1 / 2009-08-06
|
117
155
|
|
118
156
|
* Minor enhancements
|
119
|
-
|
120
|
-
|
121
|
-
a Rack::MockSession
|
157
|
+
* Support initializing a `Rack::Test::Session` with an app in addition to
|
158
|
+
a `Rack::MockSession`
|
122
159
|
* Allow CONTENT_TYPE to be specified in the env and not overwritten when
|
123
160
|
sending a POST or PUT
|
124
161
|
|
125
|
-
|
162
|
+
## 0.4.0 / 2009-06-25
|
126
163
|
|
127
164
|
* Minor enhancements
|
128
|
-
|
129
|
-
* Expose hook for building Rack::MockSessions for frameworks that need
|
165
|
+
* Expose hook for building `Rack::MockSessions` for frameworks that need
|
130
166
|
to configure them before use
|
131
167
|
* Support passing in arrays of raw cookies in addition to a newline
|
132
168
|
separated string
|
133
169
|
* Support after_request callbacks in MockSession for things like running
|
134
170
|
background jobs
|
135
171
|
* Allow multiple named sessions using with_session
|
136
|
-
* Initialize Rack::Test::Sessions with Rack::MockSessions instead of apps.
|
172
|
+
* Initialize `Rack::Test::Sessions` with `Rack::MockSessions` instead of apps.
|
137
173
|
This change should help integration with other Ruby web frameworks
|
138
174
|
(like Merb).
|
139
175
|
* Support sending bodies for PUT requests (Larry Diehl)
|
140
176
|
|
141
|
-
|
177
|
+
## 0.3.0 / 2009-05-17
|
142
178
|
|
143
179
|
* Major enhancements
|
144
|
-
|
145
180
|
* Ruby 1.9 compatible (Simon Rozet, Michael Fellinger)
|
146
|
-
|
147
181
|
* Minor enhancements
|
148
|
-
|
149
|
-
* Add CookieJar#[] and CookieJar#[]= methods
|
182
|
+
* Add `CookieJar#[]` and `CookieJar#[]=` methods
|
150
183
|
* Make the default host configurable
|
151
|
-
* Use Rack::Lint and fix errors (Simon Rozet)
|
152
|
-
* Extract Rack::MockSession from Rack::Test::Session to handle tracking
|
184
|
+
* Use `Rack::Lint` and fix errors (Simon Rozet)
|
185
|
+
* Extract `Rack::MockSession` from `Rack::Test::Session` to handle tracking
|
153
186
|
the last request and response and the cookie jar
|
154
187
|
* Add #set_cookie and #clear_cookies methods
|
155
188
|
* Rename #authorize to #basic_authorize (#authorize remains as an alias)
|
156
189
|
(Simon Rozet)
|
157
190
|
|
158
|
-
|
191
|
+
## 0.2.0 / 2009-04-26
|
159
192
|
|
160
|
-
Because
|
161
|
-
|
193
|
+
Because `#last_response` is now a `MockResponse` instead of a `Rack::Response`, `#last_response.body`
|
194
|
+
now returns a string instead of an array.
|
162
195
|
|
163
196
|
* Major enhancements
|
164
|
-
|
165
197
|
* Support multipart requests via the UploadedFile class (thanks, Rails)
|
166
|
-
|
167
198
|
* Minor enhancements
|
168
|
-
|
169
199
|
* Updated for Rack 1.0
|
170
200
|
* Don't require rubygems (See http://gist.github.com/54177)
|
171
|
-
* Support HTTP Digest authentication with the
|
172
|
-
*
|
201
|
+
* Support HTTP Digest authentication with the `#digest_authorize` method
|
202
|
+
* `#last_response` returns a `MockResponse` instead of a Response
|
173
203
|
(Michael Fellinger)
|
174
204
|
|
175
|
-
|
205
|
+
## 0.1.0 / 2009-03-02
|
176
206
|
|
177
207
|
* 1 major enhancement
|
178
|
-
|
179
208
|
* Birthday!
|
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
|
+
[<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/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/codeclimate/codeclimate)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/codeclimate/codeclimate/badges/coverage.svg)](https://codeclimate.com/github/codeclimate/codeclimate/coverage)
|
6
|
+
|
7
|
+
Code: https://github.com/rack-test/rack-test
|
8
|
+
|
9
|
+
## Description
|
10
|
+
|
11
|
+
Rack::Test is a small, simple testing API for Rack apps. It can be used on its
|
12
|
+
own or as a reusable starting point for Web frameworks and testing libraries
|
13
|
+
to build on.
|
14
|
+
|
15
|
+
## Features
|
16
|
+
|
17
|
+
* Maintains a cookie jar across requests
|
18
|
+
* Easily follow redirects when desired
|
19
|
+
* Set request headers to be used by all subsequent requests
|
20
|
+
* Small footprint. Approximately 200 LOC
|
21
|
+
|
22
|
+
## Supported platforms
|
23
|
+
|
24
|
+
* 2.2.2+
|
25
|
+
* 2.3
|
26
|
+
* 2.4
|
27
|
+
* JRuby 9.1.+
|
28
|
+
|
29
|
+
If you are using Ruby 1.8, 1.9 or JRuby 1.7, use rack-test 0.6.3.
|
30
|
+
|
31
|
+
## Examples
|
32
|
+
(The examples use `Test::Unit` but it's equally possible to use `rack-test` with other testing frameworks like `rspec`.)
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require "test/unit"
|
36
|
+
require "rack/test"
|
37
|
+
|
38
|
+
class HomepageTest < Test::Unit::TestCase
|
39
|
+
include Rack::Test::Methods
|
40
|
+
|
41
|
+
def app
|
42
|
+
app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['All responses are OK']] }
|
43
|
+
builder = Rack::Builder.new
|
44
|
+
builder.run app
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_response_is_ok
|
48
|
+
get '/'
|
49
|
+
|
50
|
+
assert last_response.ok?
|
51
|
+
assert_equal last_response.body, 'All responses are OK'
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_request_headers
|
55
|
+
headers 'Accept-Charset', 'utf-8'
|
56
|
+
get '/'
|
57
|
+
|
58
|
+
assert last_response.ok?
|
59
|
+
assert_equal last_response.body, 'All responses are OK'
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_response_is_ok_for_other_paths
|
63
|
+
get '/other_paths'
|
64
|
+
|
65
|
+
assert last_response.ok?
|
66
|
+
assert_equal last_response.body, 'All responses are OK'
|
67
|
+
end
|
68
|
+
|
69
|
+
def post_with_json
|
70
|
+
# No assertion in this, we just demonstrate how you can post a JSON-encoded string.
|
71
|
+
# By default, Rack::Test will use HTTP form encoding if you pass in a Hash as the
|
72
|
+
# parameters, so make sure that `json` below is already a JSON-serialized string.
|
73
|
+
post(uri, json, { 'CONTENT_TYPE' => 'application/json' })
|
74
|
+
end
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
If you want to test one app in isolation, you just return that app as shown above. But if you want to test the entire app stack, including middlewares, cascades etc. you need to parse the app defined in config.ru.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
OUTER_APP = Rack::Builder.parse_file("config.ru").first
|
82
|
+
|
83
|
+
class TestApp < Test::Unit::TestCase
|
84
|
+
include Rack::Test::Methods
|
85
|
+
|
86
|
+
def app
|
87
|
+
OUTER_APP
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_root
|
91
|
+
get "/"
|
92
|
+
assert last_response.ok?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
## Install
|
99
|
+
|
100
|
+
To install the latest release as a gem:
|
101
|
+
|
102
|
+
```
|
103
|
+
gem install rack-test
|
104
|
+
```
|
105
|
+
|
106
|
+
Or via Bundler:
|
107
|
+
|
108
|
+
```
|
109
|
+
gem 'rack-test', require: 'rack/test'
|
110
|
+
```
|
111
|
+
|
112
|
+
Or to install unreleased version via Bundler:
|
113
|
+
|
114
|
+
```
|
115
|
+
gem 'rack-test', github: 'rack-test', branch: 'master'
|
116
|
+
```
|
117
|
+
|
118
|
+
## Authors
|
119
|
+
|
120
|
+
- Contributions from Bryan Helmkamp, Simon Rozet, Pat Nakajima and others
|
121
|
+
- Much of the original code was extracted from Merb 1.0's request helper
|
122
|
+
|
123
|
+
## License
|
124
|
+
`rack-test` is released under the [MIT License](MIT-LICENSE.txt).
|
125
|
+
|
126
|
+
## Contribution
|
127
|
+
|
128
|
+
Contributions are welcome. Please make sure to:
|
129
|
+
|
130
|
+
* Use a regular forking workflow
|
131
|
+
* Write tests for the new or changed behaviour
|
132
|
+
* Provide an explanation/motivation in your commit message / PR message
|
133
|
+
* Ensure History.txt is updated
|
134
|
+
|
135
|
+
## Releasing
|
136
|
+
|
137
|
+
* Ensure History.txt is up-to-date
|
138
|
+
* Bump VERSION in lib/rack/test/version.rb
|
139
|
+
* bundle exec thor :release
|
data/lib/rack/mock_session.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module Rack
|
2
|
-
|
3
2
|
class MockSession # :nodoc:
|
4
3
|
attr_writer :cookie_jar
|
5
4
|
attr_reader :default_host
|
@@ -25,16 +24,16 @@ module Rack
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def request(uri, env)
|
28
|
-
env[
|
27
|
+
env['HTTP_COOKIE'] ||= cookie_jar.for(uri)
|
29
28
|
@last_request = Rack::Request.new(env)
|
30
29
|
status, headers, body = @app.call(@last_request.env)
|
31
30
|
|
32
|
-
@last_response = MockResponse.new(status, headers, body, env[
|
31
|
+
@last_response = MockResponse.new(status, headers, body, env['rack.errors'].flush)
|
33
32
|
body.close if body.respond_to?(:close)
|
34
33
|
|
35
|
-
cookie_jar.merge(last_response.headers[
|
34
|
+
cookie_jar.merge(last_response.headers['Set-Cookie'], uri)
|
36
35
|
|
37
|
-
@after_request.each
|
36
|
+
@after_request.each(&:call)
|
38
37
|
|
39
38
|
if @last_response.respond_to?(:finish)
|
40
39
|
@last_response.finish
|
@@ -46,21 +45,19 @@ module Rack
|
|
46
45
|
# Return the last request issued in the session. Raises an error if no
|
47
46
|
# requests have been sent yet.
|
48
47
|
def last_request
|
49
|
-
raise Rack::Test::Error
|
48
|
+
raise Rack::Test::Error, 'No request yet. Request a page first.' unless @last_request
|
50
49
|
@last_request
|
51
50
|
end
|
52
51
|
|
53
52
|
# Return the last response received in the session. Raises an error if
|
54
53
|
# no requests have been sent yet.
|
55
54
|
def last_response
|
56
|
-
raise Rack::Test::Error
|
55
|
+
raise Rack::Test::Error, 'No response yet. Request a page first.' unless @last_response
|
57
56
|
@last_response
|
58
57
|
end
|
59
58
|
|
60
59
|
def cookie_jar
|
61
60
|
@cookie_jar ||= Rack::Test::CookieJar.new([], @default_host)
|
62
61
|
end
|
63
|
-
|
64
62
|
end
|
65
|
-
|
66
63
|
end
|