htty 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.markdown +46 -0
- data/README.markdown +12 -12
- data/VERSION +1 -1
- data/lib/htty/cli.rb +10 -0
- data/lib/htty/cli/command.rb +50 -41
- data/lib/htty/cli/commands/http_put.rb +3 -0
- data/lib/htty/cli/commands/query_unset.rb +4 -2
- data/lib/htty/cli/http_method_command.rb +5 -3
- data/spec/integration/htty/cli/commands/query_add_spec.rb +51 -0
- data/spec/integration/htty/cli/commands/query_remove_spec.rb +37 -0
- data/spec/integration/htty/cli/commands/query_set_spec.rb +72 -0
- data/spec/integration/htty/cli/commands/query_unset_spec.rb +37 -0
- data/spec/unit/htty/cli/commands/address_spec.rb +103 -0
- data/spec/unit/htty/cli/commands/body_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/body_request_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/body_response_spec.rb +70 -0
- data/spec/unit/htty/cli/commands/body_set_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/body_unset_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/cd_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/cookie_add_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/cookies_add_spec.rb +78 -0
- data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/cookies_spec.rb +76 -0
- data/spec/unit/htty/cli/commands/cookies_use_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/delete_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/exit_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/follow_spec.rb +70 -0
- data/spec/unit/htty/cli/commands/form_add_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/form_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +66 -0
- data/spec/unit/htty/cli/commands/form_remove_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/form_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/fragment_set_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/get_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/header_set_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/header_unset_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/headers_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/headers_request_spec.rb +81 -0
- data/spec/unit/htty/cli/commands/headers_response_spec.rb +77 -0
- data/spec/unit/htty/cli/commands/headers_set_spec.rb +74 -0
- data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/headers_unset_spec.rb +63 -0
- data/spec/unit/htty/cli/commands/help_spec.rb +67 -0
- data/spec/unit/htty/cli/commands/history_spec.rb +65 -0
- data/spec/unit/htty/cli/commands/history_verbose_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/host_set_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/http_delete_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/http_get_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/http_head_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/http_options_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/http_post_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/http_put_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/http_trace_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/path_set_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/port_set_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/post_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/put_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/query_add_spec.rb +67 -36
- data/spec/unit/htty/cli/commands/query_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/query_remove_spec.rb +69 -24
- data/spec/unit/htty/cli/commands/query_set_spec.rb +59 -49
- data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/query_unset_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/quit_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/reuse_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/scheme_set_spec.rb +74 -0
- data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +67 -0
- data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +60 -0
- data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +65 -0
- data/spec/unit/htty/cli/commands/status_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/undo_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +72 -0
- data/spec/unit/htty/cli_spec.rb +8 -2
- data/spec/unit/htty/ordered_hash_spec.rb +14 -24
- data/spec/unit/htty/preferences_spec.rb +1 -1
- data/spec/unit/htty/request_spec.rb +454 -463
- metadata +80 -20
|
@@ -3,6 +3,6 @@ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/preferences
|
|
|
3
3
|
|
|
4
4
|
describe HTTY::Preferences do
|
|
5
5
|
it 'should maintain current preferences' do
|
|
6
|
-
HTTY::Preferences.current.should
|
|
6
|
+
HTTY::Preferences.current.should == HTTY::Preferences.current
|
|
7
7
|
end
|
|
8
8
|
end
|
|
@@ -5,105 +5,97 @@ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/response")
|
|
|
5
5
|
|
|
6
6
|
shared_examples_for 'an empty request' do
|
|
7
7
|
it 'should have only the default headers' do
|
|
8
|
-
|
|
8
|
+
request.headers.should == [['User-Agent', "htty/#{HTTY::VERSION}"]]
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it 'should have no body' do
|
|
12
|
-
|
|
12
|
+
request.body.should be_nil
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'should have no response' do
|
|
16
|
-
|
|
16
|
+
request.response.should be_nil
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
shared_examples_for 'an empty, authenticated request' do
|
|
21
21
|
it 'should the expected Authorization header plus the default headers' do
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
request.headers.should == [['User-Agent', "htty/#{HTTY::VERSION}"],
|
|
23
|
+
['Authorization', 'Basic bmpvbnNzb24=']]
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it 'should have no body' do
|
|
27
|
-
|
|
27
|
+
request.body.should be_nil
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it 'should have no response' do
|
|
31
|
-
|
|
31
|
+
request.response.should be_nil
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
describe HTTY::Request do
|
|
36
36
|
describe 'initializing with' do
|
|
37
|
+
let :klass do
|
|
38
|
+
HTTY::Request
|
|
39
|
+
end
|
|
40
|
+
|
|
37
41
|
describe 'an invalid IPv4 address having' do
|
|
38
42
|
describe 'consecutive dots' do
|
|
39
43
|
it 'should raise URI::InvalidURIError' do
|
|
40
|
-
expect {
|
|
41
|
-
HTTY::Request.new '1.2.3..4'
|
|
42
|
-
}.to raise_error(URI::InvalidURIError)
|
|
44
|
+
expect { klass.new '1.2.3..4' }.to raise_error(URI::InvalidURIError)
|
|
43
45
|
end
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
describe 'no dots' do
|
|
47
49
|
it 'should raise URI::InvalidURIError' do
|
|
48
|
-
expect {
|
|
49
|
-
HTTY::Request.new '1234'
|
|
50
|
-
}.to raise_error(URI::InvalidURIError)
|
|
50
|
+
expect { klass.new '1234' }.to raise_error(URI::InvalidURIError)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
describe 'too few dotted decimals' do
|
|
55
55
|
it 'should raise URI::InvalidURIError' do
|
|
56
|
-
expect {
|
|
57
|
-
HTTY::Request.new '1.2.3'
|
|
58
|
-
}.to raise_error(URI::InvalidURIError)
|
|
56
|
+
expect { klass.new '1.2.3' }.to raise_error(URI::InvalidURIError)
|
|
59
57
|
end
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
describe 'too many dotted decimals' do
|
|
63
61
|
it 'should raise URI::InvalidURIError' do
|
|
64
|
-
expect {
|
|
65
|
-
HTTY::Request.new '1.2.3.4.5'
|
|
66
|
-
}.to raise_error(URI::InvalidURIError)
|
|
62
|
+
expect { klass.new '1.2.3.4.5' }.to raise_error(URI::InvalidURIError)
|
|
67
63
|
end
|
|
68
64
|
end
|
|
69
65
|
|
|
70
66
|
describe 'a dotted decimal out of range' do
|
|
71
67
|
it 'should raise URI::InvalidURIError' do
|
|
72
|
-
expect {
|
|
73
|
-
HTTY::Request.new '1.2.3.1000'
|
|
74
|
-
}.to raise_error(URI::InvalidURIError)
|
|
68
|
+
expect { klass.new '1.2.3.1000' }.to raise_error(URI::InvalidURIError)
|
|
75
69
|
end
|
|
76
70
|
end
|
|
77
71
|
end
|
|
78
72
|
|
|
79
73
|
describe 'an invalid hostname having a leading hyphen' do
|
|
80
74
|
it 'should raise URI::InvalidURIError' do
|
|
81
|
-
expect {
|
|
82
|
-
HTTY::Request.new '-google.com'
|
|
83
|
-
}.to raise_error(URI::InvalidURIError)
|
|
75
|
+
expect { klass.new '-google.com' }.to raise_error(URI::InvalidURIError)
|
|
84
76
|
end
|
|
85
77
|
end
|
|
86
78
|
end
|
|
87
79
|
|
|
88
80
|
describe 'with a nil address' do
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
let :request do
|
|
82
|
+
HTTY::Request.new nil
|
|
91
83
|
end
|
|
92
84
|
|
|
93
85
|
it 'should have the URI http://0.0.0.0:80/' do
|
|
94
|
-
|
|
86
|
+
request.uri.should == URI.parse('http://0.0.0.0:80/')
|
|
95
87
|
end
|
|
96
88
|
|
|
97
89
|
it_should_behave_like 'an empty request'
|
|
98
90
|
end
|
|
99
91
|
|
|
100
92
|
describe 'with an empty address' do
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
let :request do
|
|
94
|
+
HTTY::Request.new ''
|
|
103
95
|
end
|
|
104
96
|
|
|
105
97
|
it 'should have the URI http://0.0.0.0:80/' do
|
|
106
|
-
|
|
98
|
+
request.uri.should == URI.parse('http://0.0.0.0:80/')
|
|
107
99
|
end
|
|
108
100
|
|
|
109
101
|
it_should_behave_like 'an empty request'
|
|
@@ -111,24 +103,24 @@ describe HTTY::Request do
|
|
|
111
103
|
|
|
112
104
|
describe 'with an address consisting of' do
|
|
113
105
|
describe 'an IPv4 address' do
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
let :request do
|
|
107
|
+
HTTY::Request.new '127.0.0.1'
|
|
116
108
|
end
|
|
117
109
|
|
|
118
110
|
it 'should have an HTTP URI for that host' do
|
|
119
|
-
|
|
111
|
+
request.uri.should == URI.parse('http://127.0.0.1:80/')
|
|
120
112
|
end
|
|
121
113
|
|
|
122
114
|
it_should_behave_like 'an empty request'
|
|
123
115
|
end
|
|
124
116
|
|
|
125
117
|
describe 'a hostname' do
|
|
126
|
-
|
|
127
|
-
|
|
118
|
+
let :request do
|
|
119
|
+
HTTY::Request.new 'localhost'
|
|
128
120
|
end
|
|
129
121
|
|
|
130
122
|
it 'should have HTTP URI for that host' do
|
|
131
|
-
|
|
123
|
+
request.uri.should == URI.parse('http://localhost:80/')
|
|
132
124
|
end
|
|
133
125
|
|
|
134
126
|
it_should_behave_like 'an empty request'
|
|
@@ -136,11 +128,11 @@ describe HTTY::Request do
|
|
|
136
128
|
describe '-- when sent #query_set' do
|
|
137
129
|
describe 'with a query parameter --' do
|
|
138
130
|
before :each do
|
|
139
|
-
|
|
131
|
+
request.query_set 'foo', 'bar'
|
|
140
132
|
end
|
|
141
133
|
|
|
142
134
|
it 'should have a URI including the query parameter' do
|
|
143
|
-
|
|
135
|
+
request.uri.should == URI.parse('http://localhost:80/?foo=bar')
|
|
144
136
|
end
|
|
145
137
|
|
|
146
138
|
it_should_behave_like 'an empty request'
|
|
@@ -149,141 +141,139 @@ describe HTTY::Request do
|
|
|
149
141
|
end
|
|
150
142
|
|
|
151
143
|
describe 'a hostname and a port' do
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
let :request do
|
|
145
|
+
HTTY::Request.new 'localhost:8080'
|
|
154
146
|
end
|
|
155
147
|
|
|
156
148
|
it 'should have an HTTP URI for that host on that port' do
|
|
157
|
-
|
|
149
|
+
request.uri.should == URI.parse('http://localhost:8080/')
|
|
158
150
|
end
|
|
159
151
|
|
|
160
152
|
it_should_behave_like 'an empty request'
|
|
161
153
|
end
|
|
162
154
|
|
|
163
155
|
describe 'the HTTP scheme and a hostname' do
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
let :request do
|
|
157
|
+
HTTY::Request.new 'http://localhost'
|
|
166
158
|
end
|
|
167
159
|
|
|
168
160
|
it 'should have an HTTP URI for that host' do
|
|
169
|
-
|
|
161
|
+
request.uri.should == URI.parse('http://localhost:80/')
|
|
170
162
|
end
|
|
171
163
|
|
|
172
164
|
it_should_behave_like 'an empty request'
|
|
173
165
|
end
|
|
174
166
|
|
|
175
167
|
describe 'the HTTPS scheme, userinfo, and a hostname' do
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
let :request do
|
|
169
|
+
HTTY::Request.new 'https://njonsson@github.com'
|
|
178
170
|
end
|
|
179
171
|
|
|
180
172
|
it 'should have an HTTPS URI for host with that userinfo' do
|
|
181
|
-
|
|
173
|
+
request.uri.should == URI.parse('https://njonsson@github.com:443/')
|
|
182
174
|
end
|
|
183
175
|
|
|
184
176
|
it_should_behave_like 'an empty, authenticated request'
|
|
185
177
|
end
|
|
186
178
|
|
|
187
179
|
describe 'a hostname and the root path' do
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
let :request do
|
|
181
|
+
HTTY::Request.new 'github.com/'
|
|
190
182
|
end
|
|
191
183
|
|
|
192
184
|
it 'should have an HTTP URI for the root of that host' do
|
|
193
|
-
|
|
185
|
+
request.uri.should == URI.parse('http://github.com:80/')
|
|
194
186
|
end
|
|
195
187
|
|
|
196
188
|
it_should_behave_like 'an empty request'
|
|
197
189
|
end
|
|
198
190
|
|
|
199
191
|
describe 'a hostname, port 443, and the root path' do
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
let :request do
|
|
193
|
+
HTTY::Request.new 'github.com:443/'
|
|
202
194
|
end
|
|
203
195
|
|
|
204
196
|
it 'should have an HTTPS URI for the root of that host' do
|
|
205
|
-
|
|
197
|
+
request.uri.should == URI.parse('https://github.com:443/')
|
|
206
198
|
end
|
|
207
199
|
|
|
208
200
|
it_should_behave_like 'an empty request'
|
|
209
201
|
end
|
|
210
202
|
|
|
211
203
|
describe 'the HTTP scheme, a hostname, port 443, and the root path' do
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
let :request do
|
|
205
|
+
HTTY::Request.new 'http://github.com:443/'
|
|
214
206
|
end
|
|
215
207
|
|
|
216
208
|
it 'should have an HTTP URI for the root of that host on port 443' do
|
|
217
|
-
|
|
209
|
+
request.uri.should == URI.parse('http://github.com:443/')
|
|
218
210
|
end
|
|
219
211
|
|
|
220
212
|
it_should_behave_like 'an empty request'
|
|
221
213
|
end
|
|
222
214
|
|
|
223
215
|
describe 'a hostname and a path' do
|
|
224
|
-
|
|
225
|
-
|
|
216
|
+
let :request do
|
|
217
|
+
HTTY::Request.new 'github.com/explore'
|
|
226
218
|
end
|
|
227
219
|
|
|
228
220
|
it 'should have an HTTP URI for that path on that host' do
|
|
229
|
-
|
|
221
|
+
request.uri.should == URI.parse('http://github.com:80/explore')
|
|
230
222
|
end
|
|
231
223
|
|
|
232
224
|
it_should_behave_like 'an empty request'
|
|
233
225
|
end
|
|
234
226
|
|
|
235
227
|
describe 'a hostname and a query string' do
|
|
236
|
-
|
|
237
|
-
|
|
228
|
+
let :request do
|
|
229
|
+
HTTY::Request.new 'github.com?search=http'
|
|
238
230
|
end
|
|
239
231
|
|
|
240
232
|
it 'should have an HTTP URI for that query string and the root of ' +
|
|
241
233
|
'that host' do
|
|
242
|
-
|
|
234
|
+
request.uri.should == URI.parse('http://github.com:80/?search=http')
|
|
243
235
|
end
|
|
244
236
|
|
|
245
237
|
it_should_behave_like 'an empty request'
|
|
246
238
|
end
|
|
247
239
|
|
|
248
240
|
describe 'a hostname, a path, and a query string' do
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
let :request do
|
|
242
|
+
HTTY::Request.new 'github.com/search?q=http&lang=en'
|
|
251
243
|
end
|
|
252
244
|
|
|
253
245
|
it 'should have an HTTP URI for that query string and that path on ' +
|
|
254
246
|
'that host' do
|
|
255
|
-
|
|
256
|
-
|
|
247
|
+
request.uri.should == URI.parse('http://github.com:80' +
|
|
248
|
+
'/search?q=http&lang=en')
|
|
257
249
|
end
|
|
258
250
|
|
|
259
251
|
it_should_behave_like 'an empty request'
|
|
260
252
|
end
|
|
261
253
|
|
|
262
254
|
describe 'a hostname, a path, and a fragment' do
|
|
263
|
-
|
|
264
|
-
|
|
255
|
+
let :request do
|
|
256
|
+
HTTY::Request.new 'github.com/explore#trending'
|
|
265
257
|
end
|
|
266
258
|
|
|
267
259
|
it 'should have an HTTP URI for that fragment of that path on that ' +
|
|
268
260
|
'host' do
|
|
269
|
-
|
|
270
|
-
'/explore#trending')
|
|
261
|
+
request.uri.should == URI.parse('http://github.com:80/explore#trending')
|
|
271
262
|
end
|
|
272
263
|
|
|
273
264
|
it_should_behave_like 'an empty request'
|
|
274
265
|
end
|
|
275
266
|
|
|
276
267
|
describe 'a hostname, a port, a path, a query string, and a fragment' do
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
'?q=http&lang=en#content')
|
|
268
|
+
let :request do
|
|
269
|
+
HTTY::Request.new 'github.com:123/search/deep?q=http&lang=en#content'
|
|
280
270
|
end
|
|
281
271
|
|
|
282
272
|
it 'should have an HTTP URI for that query string and that fragment ' +
|
|
283
273
|
'of that path on that host on that port' do
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
274
|
+
request.uri.should == URI.parse('http://github.com:123' +
|
|
275
|
+
'/search/deep?q=http&lang=en' +
|
|
276
|
+
'#content')
|
|
287
277
|
end
|
|
288
278
|
|
|
289
279
|
it_should_behave_like 'an empty request'
|
|
@@ -291,23 +281,23 @@ describe HTTY::Request do
|
|
|
291
281
|
|
|
292
282
|
describe 'the HTTPS scheme, userinfo, a hostname, a port, a path, a ' +
|
|
293
283
|
'query string, and a fragment' do
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
284
|
+
let :request do
|
|
285
|
+
HTTY::Request.new 'https://njonsson@github.com:123' +
|
|
286
|
+
'/search/deep?q=http&lang=en#content'
|
|
297
287
|
end
|
|
298
288
|
|
|
299
289
|
describe 'and without a response' do
|
|
300
290
|
it 'should not have a response' do
|
|
301
|
-
|
|
291
|
+
request.response.should be_nil
|
|
302
292
|
end
|
|
303
293
|
|
|
304
294
|
describe '-- and is untouched --' do
|
|
305
295
|
it 'should have an HTTPS URI for that query string and that ' +
|
|
306
296
|
'fragment of that path on that host on that port with that ' +
|
|
307
297
|
'userinfo' do
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
298
|
+
request.uri.should == URI.parse('https://njonsson@github.com:123' +
|
|
299
|
+
'/search/deep?q=http&lang=en' +
|
|
300
|
+
'#content')
|
|
311
301
|
end
|
|
312
302
|
|
|
313
303
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -317,42 +307,42 @@ describe HTTY::Request do
|
|
|
317
307
|
describe 'the HTTP scheme and different userinfo, hostname, port, ' +
|
|
318
308
|
'path, query string, and fragment --' do
|
|
319
309
|
before :each do
|
|
320
|
-
|
|
321
|
-
|
|
310
|
+
request.address 'http://steve@mac.com:456/archives/2010' +
|
|
311
|
+
'?author=jobs&subject=html5#flames'
|
|
322
312
|
end
|
|
323
313
|
|
|
324
314
|
it 'should have an HTTP URI for the new query string and the new ' +
|
|
325
315
|
'fragment of the new path on the new host on the new port ' +
|
|
326
316
|
'with the new userinfo' do
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
317
|
+
request.uri.should == URI.parse('http://steve@mac.com:456' +
|
|
318
|
+
'/archives/2010' +
|
|
319
|
+
'?author=jobs&subject=html5' +
|
|
320
|
+
'#flames')
|
|
331
321
|
end
|
|
332
322
|
|
|
333
323
|
it 'should the expected Authorization header plus the default ' +
|
|
334
324
|
'headers' do
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
325
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
326
|
+
HTTY::VERSION],
|
|
327
|
+
['Authorization', 'Basic c3RldmU=']]
|
|
338
328
|
end
|
|
339
329
|
|
|
340
330
|
it 'should have no body' do
|
|
341
|
-
|
|
331
|
+
request.body.should be_nil
|
|
342
332
|
end
|
|
343
333
|
|
|
344
334
|
it 'should have no response' do
|
|
345
|
-
|
|
335
|
+
request.response.should be_nil
|
|
346
336
|
end
|
|
347
337
|
end
|
|
348
338
|
|
|
349
339
|
describe 'a different hostname --' do
|
|
350
340
|
before :each do
|
|
351
|
-
|
|
341
|
+
request.address 'mac.com'
|
|
352
342
|
end
|
|
353
343
|
|
|
354
344
|
it 'should have an HTTP URI for the new host' do
|
|
355
|
-
|
|
345
|
+
request.uri.should == URI.parse('http://mac.com:80/')
|
|
356
346
|
end
|
|
357
347
|
|
|
358
348
|
it_should_behave_like 'an empty request'
|
|
@@ -362,14 +352,14 @@ describe HTTY::Request do
|
|
|
362
352
|
describe '-- when sent #scheme_set with' do
|
|
363
353
|
describe 'the same scheme --' do
|
|
364
354
|
before :each do
|
|
365
|
-
|
|
355
|
+
request.scheme_set 'https'
|
|
366
356
|
end
|
|
367
357
|
|
|
368
358
|
it 'should have an unchanged URI' do
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
359
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
360
|
+
':123' +
|
|
361
|
+
'/search/deep?q=http&lang=en' +
|
|
362
|
+
'#content')
|
|
373
363
|
end
|
|
374
364
|
|
|
375
365
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -377,14 +367,14 @@ describe HTTY::Request do
|
|
|
377
367
|
|
|
378
368
|
describe 'a different scheme --' do
|
|
379
369
|
before :each do
|
|
380
|
-
|
|
370
|
+
request.scheme_set 'http'
|
|
381
371
|
end
|
|
382
372
|
|
|
383
373
|
it 'should have the same URI, with the changed scheme' do
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
374
|
+
request.uri.should == URI.parse('http://njonsson@github.com' +
|
|
375
|
+
':123' +
|
|
376
|
+
'/search/deep?q=http&lang=en' +
|
|
377
|
+
'#content')
|
|
388
378
|
end
|
|
389
379
|
|
|
390
380
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -394,14 +384,14 @@ describe HTTY::Request do
|
|
|
394
384
|
describe '-- when sent #userinfo_set with' do
|
|
395
385
|
describe 'the same userinfo --' do
|
|
396
386
|
before :each do
|
|
397
|
-
|
|
387
|
+
request.userinfo_set 'njonsson'
|
|
398
388
|
end
|
|
399
389
|
|
|
400
390
|
it 'should have an unchanged URI' do
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
391
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
392
|
+
':123' +
|
|
393
|
+
'/search/deep?q=http&lang=en' +
|
|
394
|
+
'#content')
|
|
405
395
|
end
|
|
406
396
|
|
|
407
397
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -410,55 +400,55 @@ describe HTTY::Request do
|
|
|
410
400
|
describe 'different userinfo' do
|
|
411
401
|
describe "that does not contain '@' --" do
|
|
412
402
|
before :each do
|
|
413
|
-
|
|
403
|
+
request.userinfo_set 'nils'
|
|
414
404
|
end
|
|
415
405
|
|
|
416
406
|
it 'should have the same URI, with the changed userinfo' do
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
407
|
+
request.uri.should == URI.parse('https://nils@github.com:123' +
|
|
408
|
+
'/search/deep?q=http&lang=en' +
|
|
409
|
+
'#content')
|
|
420
410
|
end
|
|
421
411
|
|
|
422
412
|
it 'should the expected Authorization header plus the default ' +
|
|
423
413
|
'headers' do
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
414
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
415
|
+
HTTY::VERSION],
|
|
416
|
+
['Authorization', 'Basic bmlscw==']]
|
|
427
417
|
end
|
|
428
418
|
|
|
429
419
|
it 'should have no body' do
|
|
430
|
-
|
|
420
|
+
request.body.should be_nil
|
|
431
421
|
end
|
|
432
422
|
|
|
433
423
|
it 'should have no response' do
|
|
434
|
-
|
|
424
|
+
request.response.should be_nil
|
|
435
425
|
end
|
|
436
426
|
end
|
|
437
427
|
|
|
438
428
|
describe "that contains an escaped '@' --" do
|
|
439
429
|
before :each do
|
|
440
|
-
|
|
430
|
+
request.userinfo_set 'n%45'
|
|
441
431
|
end
|
|
442
432
|
|
|
443
433
|
it 'should have the same URI, with the changed userinfo' do
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
434
|
+
request.uri.should == URI.parse('https://n%45@github.com:123' +
|
|
435
|
+
'/search/deep?q=http&lang=en' +
|
|
436
|
+
'#content')
|
|
447
437
|
end
|
|
448
438
|
|
|
449
439
|
it 'should the expected Authorization header plus the default ' +
|
|
450
440
|
'headers' do
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
441
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
442
|
+
HTTY::VERSION],
|
|
443
|
+
['Authorization', 'Basic bkU=']]
|
|
454
444
|
end
|
|
455
445
|
|
|
456
446
|
it 'should have no body' do
|
|
457
|
-
|
|
447
|
+
request.body.should be_nil
|
|
458
448
|
end
|
|
459
449
|
|
|
460
450
|
it 'should have no response' do
|
|
461
|
-
|
|
451
|
+
request.response.should be_nil
|
|
462
452
|
end
|
|
463
453
|
end
|
|
464
454
|
end
|
|
@@ -466,13 +456,13 @@ describe HTTY::Request do
|
|
|
466
456
|
|
|
467
457
|
describe '-- when sent #userinfo_unset --' do
|
|
468
458
|
before :each do
|
|
469
|
-
|
|
459
|
+
request.userinfo_unset
|
|
470
460
|
end
|
|
471
461
|
|
|
472
462
|
it 'should have the same URI, without userinfo' do
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
463
|
+
request.uri.should == URI.parse('https://github.com:123' +
|
|
464
|
+
'/search/deep?q=http&lang=en' +
|
|
465
|
+
'#content')
|
|
476
466
|
end
|
|
477
467
|
|
|
478
468
|
it_should_behave_like 'an empty request'
|
|
@@ -481,14 +471,14 @@ describe HTTY::Request do
|
|
|
481
471
|
describe '-- when sent #host_set with' do
|
|
482
472
|
describe 'the same host --' do
|
|
483
473
|
before :each do
|
|
484
|
-
|
|
474
|
+
request.host_set 'github.com'
|
|
485
475
|
end
|
|
486
476
|
|
|
487
477
|
it 'should have an unchanged URI' do
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
478
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
479
|
+
':123' +
|
|
480
|
+
'/search/deep?q=http&lang=en' +
|
|
481
|
+
'#content')
|
|
492
482
|
end
|
|
493
483
|
|
|
494
484
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -496,14 +486,14 @@ describe HTTY::Request do
|
|
|
496
486
|
|
|
497
487
|
describe 'a different host --' do
|
|
498
488
|
before :each do
|
|
499
|
-
|
|
489
|
+
request.host_set 'gist.github.com'
|
|
500
490
|
end
|
|
501
491
|
|
|
502
492
|
it 'should have the same URI, with the changed scheme' do
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
493
|
+
request.uri.should == URI.parse('https://' +
|
|
494
|
+
'njonsson@gist.github.com:123' +
|
|
495
|
+
'/search/deep?q=http&lang=en' +
|
|
496
|
+
'#content')
|
|
507
497
|
end
|
|
508
498
|
|
|
509
499
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -513,14 +503,14 @@ describe HTTY::Request do
|
|
|
513
503
|
describe '-- when sent #port_set with' do
|
|
514
504
|
describe 'the same port --' do
|
|
515
505
|
before :each do
|
|
516
|
-
|
|
506
|
+
request.port_set 123
|
|
517
507
|
end
|
|
518
508
|
|
|
519
509
|
it 'should have an unchanged URI' do
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
510
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
511
|
+
':123' +
|
|
512
|
+
'/search/deep?q=http&lang=en' +
|
|
513
|
+
'#content')
|
|
524
514
|
end
|
|
525
515
|
|
|
526
516
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -528,14 +518,14 @@ describe HTTY::Request do
|
|
|
528
518
|
|
|
529
519
|
describe 'a different port --' do
|
|
530
520
|
before :each do
|
|
531
|
-
|
|
521
|
+
request.port_set 8888
|
|
532
522
|
end
|
|
533
523
|
|
|
534
524
|
it 'should have the same URI, with the changed scheme' do
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
525
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
526
|
+
':8888' +
|
|
527
|
+
'/search/deep?q=http&lang=en' +
|
|
528
|
+
'#content')
|
|
539
529
|
end
|
|
540
530
|
|
|
541
531
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -545,14 +535,14 @@ describe HTTY::Request do
|
|
|
545
535
|
describe '-- when sent #path_set with a path consisting of' do
|
|
546
536
|
describe 'a child reference --' do
|
|
547
537
|
before :each do
|
|
548
|
-
|
|
538
|
+
request.path_set 'foo'
|
|
549
539
|
end
|
|
550
540
|
|
|
551
541
|
it 'should have the same URI, descending to the expected path' do
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
542
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
543
|
+
':123' +
|
|
544
|
+
'/search/deep/foo' +
|
|
545
|
+
'?q=http&lang=en#content')
|
|
556
546
|
end
|
|
557
547
|
|
|
558
548
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -560,13 +550,13 @@ describe HTTY::Request do
|
|
|
560
550
|
|
|
561
551
|
describe 'a parent reference --' do
|
|
562
552
|
before :each do
|
|
563
|
-
|
|
553
|
+
request.path_set '..'
|
|
564
554
|
end
|
|
565
555
|
|
|
566
556
|
it 'should have the same URI, ascending to the expected path' do
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
557
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
558
|
+
':123' +
|
|
559
|
+
'/search?q=http&lang=en#content')
|
|
570
560
|
end
|
|
571
561
|
|
|
572
562
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -574,14 +564,14 @@ describe HTTY::Request do
|
|
|
574
564
|
|
|
575
565
|
describe 'an absolute reference --' do
|
|
576
566
|
before :each do
|
|
577
|
-
|
|
567
|
+
request.path_set '/foo/bar'
|
|
578
568
|
end
|
|
579
569
|
|
|
580
570
|
it 'should have the same URI, changing to the expected path' do
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
571
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
572
|
+
':123' +
|
|
573
|
+
'/foo/bar?q=http&lang=en' +
|
|
574
|
+
'#content')
|
|
585
575
|
end
|
|
586
576
|
|
|
587
577
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -591,11 +581,11 @@ describe HTTY::Request do
|
|
|
591
581
|
describe '-- when sent #query_set' do
|
|
592
582
|
describe 'with a new query parameter --' do
|
|
593
583
|
before :each do
|
|
594
|
-
|
|
584
|
+
request.query_set 'foo', 'bar'
|
|
595
585
|
end
|
|
596
586
|
|
|
597
587
|
it 'should have a URI including the new query parameter' do
|
|
598
|
-
|
|
588
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
599
589
|
':123' +
|
|
600
590
|
'/search/deep' +
|
|
601
591
|
'?q=http&lang=en&foo=bar' +
|
|
@@ -607,14 +597,14 @@ describe HTTY::Request do
|
|
|
607
597
|
|
|
608
598
|
describe 'with a new value for the first query parameter --' do
|
|
609
599
|
before :each do
|
|
610
|
-
|
|
600
|
+
request.query_set 'q', 'ruby'
|
|
611
601
|
end
|
|
612
602
|
|
|
613
603
|
it 'should have a URI with the new value of the query parameter' do
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
604
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
605
|
+
':123' +
|
|
606
|
+
'/search/deep?q=ruby&lang=en' +
|
|
607
|
+
'#content')
|
|
618
608
|
end
|
|
619
609
|
|
|
620
610
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -622,15 +612,15 @@ describe HTTY::Request do
|
|
|
622
612
|
|
|
623
613
|
describe 'with a new value for the second query parameter --' do
|
|
624
614
|
before :each do
|
|
625
|
-
|
|
615
|
+
request.query_set 'lang', 'fr'
|
|
626
616
|
end
|
|
627
617
|
|
|
628
618
|
it 'should have a URI with the new value of the second query ' +
|
|
629
619
|
'parameter' do
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
620
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
621
|
+
':123' +
|
|
622
|
+
'/search/deep?q=http&lang=fr' +
|
|
623
|
+
'#content')
|
|
634
624
|
end
|
|
635
625
|
|
|
636
626
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -640,14 +630,14 @@ describe HTTY::Request do
|
|
|
640
630
|
describe '-- when sent #query_unset' do
|
|
641
631
|
describe 'with a nonexistent query parameter --' do
|
|
642
632
|
before :each do
|
|
643
|
-
|
|
633
|
+
request.query_unset 'fizzle'
|
|
644
634
|
end
|
|
645
635
|
|
|
646
636
|
it 'should have an unchanged URI' do
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
637
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
638
|
+
':123' +
|
|
639
|
+
'/search/deep?q=http&lang=en' +
|
|
640
|
+
'#content')
|
|
651
641
|
end
|
|
652
642
|
|
|
653
643
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -655,13 +645,13 @@ describe HTTY::Request do
|
|
|
655
645
|
|
|
656
646
|
describe 'with the first query parameter --' do
|
|
657
647
|
before :each do
|
|
658
|
-
|
|
648
|
+
request.query_unset 'q'
|
|
659
649
|
end
|
|
660
650
|
|
|
661
651
|
it 'should have a URI missing the first query parameter' do
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
652
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
653
|
+
':123' +
|
|
654
|
+
'/search/deep?lang=en#content')
|
|
665
655
|
end
|
|
666
656
|
|
|
667
657
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -669,13 +659,13 @@ describe HTTY::Request do
|
|
|
669
659
|
|
|
670
660
|
describe 'with the second query parameter --' do
|
|
671
661
|
before :each do
|
|
672
|
-
|
|
662
|
+
request.query_unset 'lang'
|
|
673
663
|
end
|
|
674
664
|
|
|
675
665
|
it 'should have a URI missing the second query parameter' do
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
666
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
667
|
+
':123' +
|
|
668
|
+
'/search/deep?q=http#content')
|
|
679
669
|
end
|
|
680
670
|
|
|
681
671
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -684,12 +674,12 @@ describe HTTY::Request do
|
|
|
684
674
|
|
|
685
675
|
describe '-- when sent #query_unset_all --' do
|
|
686
676
|
before :each do
|
|
687
|
-
|
|
677
|
+
request.query_unset_all
|
|
688
678
|
end
|
|
689
679
|
|
|
690
680
|
it 'should have a URI having no query string' do
|
|
691
|
-
|
|
692
|
-
|
|
681
|
+
request.uri.should == URI.parse('https://njonsson@github.com:123' +
|
|
682
|
+
'/search/deep#content')
|
|
693
683
|
end
|
|
694
684
|
|
|
695
685
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -698,14 +688,14 @@ describe HTTY::Request do
|
|
|
698
688
|
describe '-- when sent #fragment_set with' do
|
|
699
689
|
describe 'the same fragment --' do
|
|
700
690
|
before :each do
|
|
701
|
-
|
|
691
|
+
request.fragment_set 'content'
|
|
702
692
|
end
|
|
703
693
|
|
|
704
694
|
it 'should have an unchanged URI' do
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
695
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
696
|
+
':123' +
|
|
697
|
+
'/search/deep?q=http&lang=en' +
|
|
698
|
+
'#content')
|
|
709
699
|
end
|
|
710
700
|
|
|
711
701
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -713,14 +703,14 @@ describe HTTY::Request do
|
|
|
713
703
|
|
|
714
704
|
describe 'different fragment --' do
|
|
715
705
|
before :each do
|
|
716
|
-
|
|
706
|
+
request.fragment_set 'details'
|
|
717
707
|
end
|
|
718
708
|
|
|
719
709
|
it 'should have the same URI, with the changed fragment' do
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
710
|
+
request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
711
|
+
':123' +
|
|
712
|
+
'/search/deep?q=http&lang=en' +
|
|
713
|
+
'#details')
|
|
724
714
|
end
|
|
725
715
|
|
|
726
716
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -729,12 +719,12 @@ describe HTTY::Request do
|
|
|
729
719
|
|
|
730
720
|
describe '-- when sent #fragment_unset --' do
|
|
731
721
|
before :each do
|
|
732
|
-
|
|
722
|
+
request.fragment_unset
|
|
733
723
|
end
|
|
734
724
|
|
|
735
725
|
it 'should have the same URI, without fragment' do
|
|
736
|
-
|
|
737
|
-
|
|
726
|
+
request.uri.should == URI.parse('https://njonsson@github.com:123' +
|
|
727
|
+
'/search/deep?q=http&lang=en')
|
|
738
728
|
end
|
|
739
729
|
|
|
740
730
|
it_should_behave_like 'an empty, authenticated request'
|
|
@@ -742,147 +732,147 @@ describe HTTY::Request do
|
|
|
742
732
|
|
|
743
733
|
describe '-- when sent #header_set with a new header' do
|
|
744
734
|
before :each do
|
|
745
|
-
|
|
735
|
+
request.header_set 'foo', 'bar'
|
|
746
736
|
end
|
|
747
737
|
|
|
748
738
|
it 'should have an unchanged URI' do
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
739
|
+
request.uri.should == URI.parse('https://njonsson@github.com:123' +
|
|
740
|
+
'/search/deep?q=http&lang=en' +
|
|
741
|
+
'#content')
|
|
752
742
|
end
|
|
753
743
|
|
|
754
744
|
describe '--' do
|
|
755
745
|
it 'should have the header, plus the default headers' do
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
746
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
747
|
+
HTTY::VERSION],
|
|
748
|
+
['Authorization', 'Basic ' +
|
|
749
|
+
'bmpvbnNzb24='],
|
|
750
|
+
['foo', 'bar']]
|
|
761
751
|
end
|
|
762
752
|
end
|
|
763
753
|
|
|
764
754
|
describe 'and then #header_unset' do
|
|
765
755
|
describe 'with the same header name --' do
|
|
766
756
|
before :each do
|
|
767
|
-
|
|
757
|
+
request.header_unset 'foo'
|
|
768
758
|
end
|
|
769
759
|
|
|
770
760
|
it 'should have only the default headers' do
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
761
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
762
|
+
HTTY::VERSION],
|
|
763
|
+
['Authorization', 'Basic ' +
|
|
764
|
+
'bmpvbnNzb24=']]
|
|
775
765
|
end
|
|
776
766
|
end
|
|
777
767
|
|
|
778
768
|
describe 'with a different header name --' do
|
|
779
769
|
before :each do
|
|
780
|
-
|
|
770
|
+
request.header_unset 'qux'
|
|
781
771
|
end
|
|
782
772
|
|
|
783
773
|
it 'should have the header, plus the default headers' do
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
774
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
775
|
+
HTTY::VERSION],
|
|
776
|
+
['Authorization', 'Basic ' +
|
|
777
|
+
'bmpvbnNzb24='],
|
|
778
|
+
['foo', 'bar']]
|
|
789
779
|
end
|
|
790
780
|
end
|
|
791
781
|
end
|
|
792
782
|
|
|
793
783
|
describe 'and then #headers_unset_all --' do
|
|
794
784
|
before :each do
|
|
795
|
-
|
|
785
|
+
request.headers_unset_all
|
|
796
786
|
end
|
|
797
787
|
|
|
798
788
|
it 'should have no headers' do
|
|
799
|
-
|
|
789
|
+
request.headers.should be_empty
|
|
800
790
|
end
|
|
801
791
|
end
|
|
802
792
|
end
|
|
803
793
|
|
|
804
794
|
describe '-- when sent #cookie_add with a cookie' do
|
|
805
795
|
before :each do
|
|
806
|
-
|
|
796
|
+
request.cookie_add 'foo', 'bar'
|
|
807
797
|
end
|
|
808
798
|
|
|
809
799
|
it 'should have an unchanged URI' do
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
800
|
+
request.uri.should == URI.parse('https://njonsson@github.com:123' +
|
|
801
|
+
'/search/deep?q=http&lang=en' +
|
|
802
|
+
'#content')
|
|
813
803
|
end
|
|
814
804
|
|
|
815
805
|
describe '--' do
|
|
816
806
|
it 'should have the cookie' do
|
|
817
|
-
|
|
807
|
+
request.cookies.should == [%w(foo bar)]
|
|
818
808
|
end
|
|
819
809
|
|
|
820
810
|
it 'should have the cookie header, plus the default headers' do
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
811
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
812
|
+
HTTY::VERSION],
|
|
813
|
+
['Authorization', 'Basic ' +
|
|
814
|
+
'bmpvbnNzb24='],
|
|
815
|
+
['Cookie', 'foo=bar']]
|
|
826
816
|
end
|
|
827
817
|
end
|
|
828
818
|
|
|
829
819
|
describe 'and then #cookie_add' do
|
|
830
820
|
describe 'with the same cookie name --' do
|
|
831
821
|
before :each do
|
|
832
|
-
|
|
822
|
+
request.cookie_add 'foo', 'qux'
|
|
833
823
|
end
|
|
834
824
|
|
|
835
825
|
it 'should have the new cookie, plus the old cookie' do
|
|
836
|
-
|
|
826
|
+
request.cookies.should == [%w(foo bar), %w(foo qux)]
|
|
837
827
|
end
|
|
838
828
|
|
|
839
829
|
it 'should have the new cookie header, plus the default ' +
|
|
840
830
|
'headers' do
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
831
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
832
|
+
HTTY::VERSION],
|
|
833
|
+
['Authorization', 'Basic ' +
|
|
834
|
+
'bmpvbnNzb24='],
|
|
835
|
+
['Cookie', 'foo=bar; ' +
|
|
836
|
+
'foo=qux']]
|
|
847
837
|
end
|
|
848
838
|
end
|
|
849
839
|
|
|
850
840
|
describe 'with a different cookie name --' do
|
|
851
841
|
before :each do
|
|
852
|
-
|
|
842
|
+
request.cookie_add 'baz', 'qux'
|
|
853
843
|
end
|
|
854
844
|
|
|
855
845
|
it 'should have the new cookie' do
|
|
856
|
-
|
|
846
|
+
request.cookies.should == [%w(foo bar), %w(baz qux)]
|
|
857
847
|
end
|
|
858
848
|
|
|
859
849
|
it 'should have the new cookie header, plus the default ' +
|
|
860
850
|
'headers' do
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
851
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
852
|
+
HTTY::VERSION],
|
|
853
|
+
['Authorization', 'Basic ' +
|
|
854
|
+
'bmpvbnNzb24='],
|
|
855
|
+
['Cookie', 'foo=bar; ' +
|
|
856
|
+
'baz=qux']]
|
|
867
857
|
end
|
|
868
858
|
end
|
|
869
859
|
|
|
870
860
|
describe 'with a different cookie name and no value --' do
|
|
871
861
|
before :each do
|
|
872
|
-
|
|
862
|
+
request.cookie_add 'baz'
|
|
873
863
|
end
|
|
874
864
|
|
|
875
865
|
it 'should have the new cookie' do
|
|
876
|
-
|
|
866
|
+
request.cookies.should == [['foo', 'bar'], ['baz', nil]]
|
|
877
867
|
end
|
|
878
868
|
|
|
879
869
|
it 'should have the new cookie header, plus the default ' +
|
|
880
870
|
'headers' do
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
871
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
872
|
+
HTTY::VERSION],
|
|
873
|
+
['Authorization', 'Basic ' +
|
|
874
|
+
'bmpvbnNzb24='],
|
|
875
|
+
['Cookie', 'foo=bar; baz']]
|
|
886
876
|
end
|
|
887
877
|
end
|
|
888
878
|
end
|
|
@@ -890,87 +880,87 @@ describe HTTY::Request do
|
|
|
890
880
|
describe 'and then #cookie_remove' do
|
|
891
881
|
describe 'with the same cookie name --' do
|
|
892
882
|
before :each do
|
|
893
|
-
|
|
883
|
+
request.cookie_remove 'foo'
|
|
894
884
|
end
|
|
895
885
|
|
|
896
886
|
it 'should have no cookie' do
|
|
897
|
-
|
|
887
|
+
request.cookies.should be_empty
|
|
898
888
|
end
|
|
899
889
|
|
|
900
890
|
it 'should have only the default headers' do
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
891
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
892
|
+
HTTY::VERSION],
|
|
893
|
+
['Authorization', 'Basic ' +
|
|
894
|
+
'bmpvbnNzb24=']]
|
|
905
895
|
end
|
|
906
896
|
end
|
|
907
897
|
|
|
908
898
|
describe 'with a different cookie name --' do
|
|
909
899
|
before :each do
|
|
910
|
-
|
|
900
|
+
request.cookie_remove 'qux'
|
|
911
901
|
end
|
|
912
902
|
|
|
913
903
|
it 'should have the cookie' do
|
|
914
|
-
|
|
904
|
+
request.cookies.should == [%w(foo bar)]
|
|
915
905
|
end
|
|
916
906
|
|
|
917
907
|
it 'should have the cookie header, plus the default headers' do
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
908
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
909
|
+
HTTY::VERSION],
|
|
910
|
+
['Authorization', 'Basic ' +
|
|
911
|
+
'bmpvbnNzb24='],
|
|
912
|
+
['Cookie', 'foo=bar']]
|
|
923
913
|
end
|
|
924
914
|
end
|
|
925
915
|
end
|
|
926
916
|
|
|
927
917
|
describe 'and then #cookies_remove_all --' do
|
|
928
918
|
before :each do
|
|
929
|
-
|
|
919
|
+
request.cookies_remove_all
|
|
930
920
|
end
|
|
931
921
|
|
|
932
922
|
it 'should have no cookies' do
|
|
933
|
-
|
|
923
|
+
request.cookies.should be_empty
|
|
934
924
|
end
|
|
935
925
|
|
|
936
926
|
it 'should have only the default headers' do
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
927
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
928
|
+
HTTY::VERSION],
|
|
929
|
+
['Authorization', 'Basic ' +
|
|
930
|
+
'bmpvbnNzb24=']]
|
|
941
931
|
end
|
|
942
932
|
end
|
|
943
933
|
|
|
944
934
|
describe 'and then #address' do
|
|
945
935
|
describe 'with the same host --' do
|
|
946
936
|
before :each do
|
|
947
|
-
|
|
937
|
+
request.address 'http://github.com'
|
|
948
938
|
end
|
|
949
939
|
|
|
950
940
|
it 'should have the cookie' do
|
|
951
|
-
|
|
941
|
+
request.cookies.should == [%w(foo bar)]
|
|
952
942
|
end
|
|
953
943
|
|
|
954
944
|
it 'should have the cookie header, plus the default headers' do
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
945
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
946
|
+
HTTY::VERSION],
|
|
947
|
+
['Cookie', 'foo=bar']]
|
|
958
948
|
end
|
|
959
949
|
end
|
|
960
950
|
|
|
961
951
|
describe 'with a different host --' do
|
|
962
952
|
before :each do
|
|
963
|
-
|
|
953
|
+
request.address 'http://google.com'
|
|
964
954
|
end
|
|
965
955
|
|
|
966
956
|
it 'should have no cookies' do
|
|
967
|
-
|
|
968
|
-
|
|
957
|
+
request.cookies.should == []
|
|
958
|
+
request.cookies.should be_empty
|
|
969
959
|
end
|
|
970
960
|
|
|
971
961
|
it 'should have only the default headers' do
|
|
972
|
-
|
|
973
|
-
|
|
962
|
+
request.headers.should == [['User-Agent',
|
|
963
|
+
"htty/#{HTTY::VERSION}"]]
|
|
974
964
|
end
|
|
975
965
|
end
|
|
976
966
|
end
|
|
@@ -978,433 +968,434 @@ describe HTTY::Request do
|
|
|
978
968
|
|
|
979
969
|
describe "-- when sent #cookie_add with a new cookie containing '='" do
|
|
980
970
|
before :each do
|
|
981
|
-
|
|
971
|
+
request.cookie_add 'foo', 'bar=baz=qux'
|
|
982
972
|
end
|
|
983
973
|
|
|
984
974
|
describe '--' do
|
|
985
975
|
it 'should have the cookie' do
|
|
986
|
-
|
|
976
|
+
request.cookies.should == [%w(foo bar=baz=qux)]
|
|
987
977
|
end
|
|
988
978
|
|
|
989
979
|
it 'should have the cookie header, plus the default headers' do
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
980
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
981
|
+
HTTY::VERSION],
|
|
982
|
+
['Authorization', 'Basic ' +
|
|
983
|
+
'bmpvbnNzb24='],
|
|
984
|
+
['Cookie', 'foo=bar=baz=qux']]
|
|
995
985
|
end
|
|
996
986
|
end
|
|
997
987
|
end
|
|
998
988
|
|
|
999
989
|
describe '-- when sent #body_set with a body' do
|
|
1000
990
|
before :each do
|
|
1001
|
-
|
|
991
|
+
request.body_set 'foo'
|
|
1002
992
|
end
|
|
1003
993
|
|
|
1004
994
|
it 'should have an unchanged URI' do
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
995
|
+
request.uri.should == URI.parse('https://njonsson@github.com:123' +
|
|
996
|
+
'/search/deep?q=http&lang=en' +
|
|
997
|
+
'#content')
|
|
1008
998
|
end
|
|
1009
999
|
|
|
1010
1000
|
describe '--' do
|
|
1011
1001
|
it 'should have the body' do
|
|
1012
|
-
|
|
1002
|
+
request.body.should == 'foo'
|
|
1013
1003
|
end
|
|
1014
1004
|
|
|
1015
1005
|
it 'should have only the default headers' do
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1006
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
1007
|
+
HTTY::VERSION],
|
|
1008
|
+
['Authorization', 'Basic ' +
|
|
1009
|
+
'bmpvbnNzb24=']]
|
|
1020
1010
|
end
|
|
1021
1011
|
|
|
1022
1012
|
it "should have the expected 'Content-Length' header, plus the " +
|
|
1023
1013
|
"'User-Agent' header if we do not exclude the " +
|
|
1024
1014
|
"'Content-Length' header" do
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1015
|
+
request.headers(true).should == [['User-Agent', 'htty/' +
|
|
1016
|
+
HTTY::VERSION],
|
|
1017
|
+
['Authorization', 'Basic ' +
|
|
1018
|
+
'bmpvbnNz' +
|
|
1019
|
+
'b24='],
|
|
1020
|
+
['Content-Length', '3']]
|
|
1031
1021
|
end
|
|
1032
1022
|
end
|
|
1033
1023
|
|
|
1034
1024
|
describe 'and then #body_unset' do
|
|
1035
1025
|
before :each do
|
|
1036
|
-
|
|
1026
|
+
request.body_unset
|
|
1037
1027
|
end
|
|
1038
1028
|
|
|
1039
1029
|
it 'should have no body' do
|
|
1040
|
-
|
|
1030
|
+
request.body.should be_nil
|
|
1041
1031
|
end
|
|
1042
1032
|
|
|
1043
1033
|
it 'should have only the default headers' do
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1034
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
1035
|
+
HTTY::VERSION],
|
|
1036
|
+
['Authorization', 'Basic ' +
|
|
1037
|
+
'bmpvbnNzb24=']]
|
|
1048
1038
|
end
|
|
1049
1039
|
end
|
|
1050
1040
|
end
|
|
1051
1041
|
end
|
|
1052
1042
|
|
|
1053
1043
|
describe 'and with a response' do
|
|
1044
|
+
let :response do
|
|
1045
|
+
HTTY::Response.new
|
|
1046
|
+
end
|
|
1047
|
+
|
|
1054
1048
|
before :each do
|
|
1055
|
-
|
|
1056
|
-
@request.send :response=, @response
|
|
1049
|
+
request.send :response=, response
|
|
1057
1050
|
end
|
|
1058
1051
|
|
|
1059
1052
|
it 'should not affect the URI' do
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1053
|
+
request.uri.should == URI.parse('https://njonsson@github.com:123' +
|
|
1054
|
+
'/search/deep?q=http&lang=en' +
|
|
1055
|
+
'#content')
|
|
1063
1056
|
end
|
|
1064
1057
|
|
|
1065
1058
|
it 'should not affect the headers' do
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1059
|
+
request.headers.should == [['User-Agent', 'htty/' +
|
|
1060
|
+
HTTY::VERSION],
|
|
1061
|
+
['Authorization', 'Basic ' +
|
|
1062
|
+
'bmpvbnNzb24=']]
|
|
1070
1063
|
end
|
|
1071
1064
|
|
|
1072
1065
|
it 'should not affect the body' do
|
|
1073
|
-
|
|
1066
|
+
request.body.should be_nil
|
|
1074
1067
|
end
|
|
1075
1068
|
|
|
1076
1069
|
it 'should not affect the response' do
|
|
1077
|
-
|
|
1070
|
+
request.response.should == response
|
|
1078
1071
|
end
|
|
1079
1072
|
|
|
1080
1073
|
describe '-- when sent #address with a different hostname --' do
|
|
1081
|
-
|
|
1082
|
-
|
|
1074
|
+
let :new_request do
|
|
1075
|
+
request.address 'mac.com'
|
|
1083
1076
|
end
|
|
1084
1077
|
|
|
1085
1078
|
it 'should return a request with an HTTP URI for the new host' do
|
|
1086
|
-
|
|
1079
|
+
new_request.uri.should == URI.parse('http://mac.com:80/')
|
|
1087
1080
|
end
|
|
1088
1081
|
|
|
1089
1082
|
it 'should return a request without a response' do
|
|
1090
|
-
|
|
1083
|
+
new_request.response.should be_nil
|
|
1091
1084
|
end
|
|
1092
1085
|
end
|
|
1093
1086
|
|
|
1094
1087
|
describe '-- when sent #scheme_set with a different scheme --' do
|
|
1095
|
-
|
|
1096
|
-
|
|
1088
|
+
let :new_request do
|
|
1089
|
+
request.scheme_set 'http'
|
|
1097
1090
|
end
|
|
1098
1091
|
|
|
1099
1092
|
it 'should return a request with the same URI having the changed ' +
|
|
1100
1093
|
'scheme' do
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1094
|
+
new_request.uri.should == URI.parse('http://njonsson@github.com' +
|
|
1095
|
+
':123' +
|
|
1096
|
+
'/search/deep?q=http&lang=en' +
|
|
1097
|
+
'#content')
|
|
1105
1098
|
end
|
|
1106
1099
|
|
|
1107
1100
|
it 'should return a request without a response' do
|
|
1108
|
-
|
|
1101
|
+
new_request.response.should be_nil
|
|
1109
1102
|
end
|
|
1110
1103
|
end
|
|
1111
1104
|
|
|
1112
1105
|
describe '-- when sent #userinfo_set with different userinfo --' do
|
|
1113
|
-
|
|
1114
|
-
|
|
1106
|
+
let :new_request do
|
|
1107
|
+
request.userinfo_set 'nils'
|
|
1115
1108
|
end
|
|
1116
1109
|
|
|
1117
1110
|
it 'should return a request with the same URI having the changed ' +
|
|
1118
1111
|
'userinfo' do
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
'?q=http&lang=en' +
|
|
1123
|
-
'#content')
|
|
1112
|
+
new_request.uri.should == URI.parse('https://nils@github.com:123' +
|
|
1113
|
+
'/search/deep?q=http&lang=en' +
|
|
1114
|
+
'#content')
|
|
1124
1115
|
end
|
|
1125
1116
|
|
|
1126
1117
|
it 'should return a request without a response' do
|
|
1127
|
-
|
|
1118
|
+
new_request.response.should be_nil
|
|
1128
1119
|
end
|
|
1129
1120
|
end
|
|
1130
1121
|
|
|
1131
1122
|
describe '-- when sent #userinfo_unset --' do
|
|
1132
|
-
|
|
1133
|
-
|
|
1123
|
+
let :new_request do
|
|
1124
|
+
request.userinfo_unset
|
|
1134
1125
|
end
|
|
1135
1126
|
|
|
1136
1127
|
it 'should return a request with the same URI not having userinfo' do
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1128
|
+
new_request.uri.should == URI.parse('https://github.com:123' +
|
|
1129
|
+
'/search/deep?q=http&lang=en' +
|
|
1130
|
+
'#content')
|
|
1140
1131
|
end
|
|
1141
1132
|
|
|
1142
1133
|
it 'should return a request without a response' do
|
|
1143
|
-
|
|
1134
|
+
new_request.response.should be_nil
|
|
1144
1135
|
end
|
|
1145
1136
|
end
|
|
1146
1137
|
|
|
1147
1138
|
describe '-- when sent #host_set with a different host --' do
|
|
1148
|
-
|
|
1149
|
-
|
|
1139
|
+
let :new_request do
|
|
1140
|
+
request.host_set 'gist.github.com'
|
|
1150
1141
|
end
|
|
1151
1142
|
|
|
1152
1143
|
it 'should return a request with the same URI having the changed ' +
|
|
1153
1144
|
'host' do
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1145
|
+
new_request.uri.should == URI.parse('https://' +
|
|
1146
|
+
'njonsson@gist.github.com' +
|
|
1147
|
+
':123' +
|
|
1148
|
+
'/search/deep?q=http&lang=en' +
|
|
1149
|
+
'#content')
|
|
1159
1150
|
end
|
|
1160
1151
|
|
|
1161
1152
|
it 'should return a request without a response' do
|
|
1162
|
-
|
|
1153
|
+
new_request.response.should be_nil
|
|
1163
1154
|
end
|
|
1164
1155
|
end
|
|
1165
1156
|
|
|
1166
1157
|
describe '-- when sent #port_set with a different port --' do
|
|
1167
|
-
|
|
1168
|
-
|
|
1158
|
+
let :new_request do
|
|
1159
|
+
request.port_set 8888
|
|
1169
1160
|
end
|
|
1170
1161
|
|
|
1171
1162
|
it 'should return a request with the same URI having the changed ' +
|
|
1172
1163
|
'port' do
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1164
|
+
new_request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
1165
|
+
':8888' +
|
|
1166
|
+
'/search/deep?q=http&lang=en' +
|
|
1167
|
+
'#content')
|
|
1177
1168
|
end
|
|
1178
1169
|
|
|
1179
1170
|
it 'should return a request without a response' do
|
|
1180
|
-
|
|
1171
|
+
new_request.response.should be_nil
|
|
1181
1172
|
end
|
|
1182
1173
|
end
|
|
1183
1174
|
|
|
1184
1175
|
describe '-- when sent #path_set with a different path --' do
|
|
1185
|
-
|
|
1186
|
-
|
|
1176
|
+
let :new_request do
|
|
1177
|
+
request.path_set 'foo'
|
|
1187
1178
|
end
|
|
1188
1179
|
|
|
1189
1180
|
it 'should return a request with the same URI having the changed ' +
|
|
1190
1181
|
'path' do
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1182
|
+
new_request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
1183
|
+
':123' +
|
|
1184
|
+
'/search/deep/foo' +
|
|
1185
|
+
'?q=http&lang=en#content')
|
|
1195
1186
|
end
|
|
1196
1187
|
|
|
1197
1188
|
it 'should return a request without a response' do
|
|
1198
|
-
|
|
1189
|
+
new_request.response.should be_nil
|
|
1199
1190
|
end
|
|
1200
1191
|
end
|
|
1201
1192
|
|
|
1202
1193
|
describe '-- when sent #query_set with a query parameter --' do
|
|
1203
|
-
|
|
1204
|
-
|
|
1194
|
+
let :new_request do
|
|
1195
|
+
request.query_set 'foo', 'bar'
|
|
1205
1196
|
end
|
|
1206
1197
|
|
|
1207
1198
|
it 'should return a request with the same URI having the new query ' +
|
|
1208
1199
|
'parameter' do
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1200
|
+
new_request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
1201
|
+
':123' +
|
|
1202
|
+
'/search/deep' +
|
|
1203
|
+
'?q=http&lang=en&foo=bar' +
|
|
1204
|
+
'#content')
|
|
1214
1205
|
end
|
|
1215
1206
|
|
|
1216
1207
|
it 'should return a request without a response' do
|
|
1217
|
-
|
|
1208
|
+
new_request.response.should be_nil
|
|
1218
1209
|
end
|
|
1219
1210
|
end
|
|
1220
1211
|
|
|
1221
1212
|
describe '-- when sent #query_unset with the first query ' +
|
|
1222
1213
|
'parameter --' do
|
|
1223
|
-
|
|
1224
|
-
|
|
1214
|
+
let :new_request do
|
|
1215
|
+
request.query_unset 'q'
|
|
1225
1216
|
end
|
|
1226
1217
|
|
|
1227
1218
|
it 'should return a request with the same URI missing the first ' +
|
|
1228
1219
|
'query parameter' do
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1220
|
+
new_request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
1221
|
+
':123' +
|
|
1222
|
+
'/search/deep?lang=en#content')
|
|
1232
1223
|
end
|
|
1233
1224
|
|
|
1234
1225
|
it 'should return a request without a response' do
|
|
1235
|
-
|
|
1226
|
+
new_request.response.should be_nil
|
|
1236
1227
|
end
|
|
1237
1228
|
end
|
|
1238
1229
|
|
|
1239
1230
|
describe '-- when sent #query_unset_all --' do
|
|
1240
|
-
|
|
1241
|
-
|
|
1231
|
+
let :new_request do
|
|
1232
|
+
request.query_unset_all
|
|
1242
1233
|
end
|
|
1243
1234
|
|
|
1244
1235
|
it 'should return a request with the same URI having no query ' +
|
|
1245
1236
|
'string' do
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1237
|
+
new_request.uri.should == URI.parse('https://' +
|
|
1238
|
+
'njonsson@github.com:123' +
|
|
1239
|
+
'/search/deep#content')
|
|
1249
1240
|
end
|
|
1250
1241
|
|
|
1251
1242
|
it 'should return a request without a response' do
|
|
1252
|
-
|
|
1243
|
+
new_request.response.should be_nil
|
|
1253
1244
|
end
|
|
1254
1245
|
end
|
|
1255
1246
|
|
|
1256
1247
|
describe '-- when sent #fragment_set with a different fragment --' do
|
|
1257
|
-
|
|
1258
|
-
|
|
1248
|
+
let :new_request do
|
|
1249
|
+
request.fragment_set 'details'
|
|
1259
1250
|
end
|
|
1260
1251
|
|
|
1261
1252
|
it 'should return a request with the same URI having the changed ' +
|
|
1262
1253
|
'fragment' do
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1254
|
+
new_request.uri.should == URI.parse('https://njonsson@github.com' +
|
|
1255
|
+
':123' +
|
|
1256
|
+
'/search/deep?q=http&lang=en' +
|
|
1257
|
+
'#details')
|
|
1267
1258
|
end
|
|
1268
1259
|
|
|
1269
1260
|
it 'should return a request without a response' do
|
|
1270
|
-
|
|
1261
|
+
new_request.response.should be_nil
|
|
1271
1262
|
end
|
|
1272
1263
|
end
|
|
1273
1264
|
|
|
1274
1265
|
describe '-- when sent #fragment_unset --' do
|
|
1275
|
-
|
|
1276
|
-
|
|
1266
|
+
let :new_request do
|
|
1267
|
+
request.fragment_unset
|
|
1277
1268
|
end
|
|
1278
1269
|
|
|
1279
1270
|
it 'should return a request with the same URI missing the fragment' do
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1271
|
+
new_request.uri.should == URI.parse('https://' +
|
|
1272
|
+
'njonsson@github.com:123' +
|
|
1273
|
+
'/search/deep?q=http&lang=en')
|
|
1283
1274
|
end
|
|
1284
1275
|
|
|
1285
1276
|
it 'should return a request without a response' do
|
|
1286
|
-
|
|
1277
|
+
new_request.response.should be_nil
|
|
1287
1278
|
end
|
|
1288
1279
|
end
|
|
1289
1280
|
|
|
1290
1281
|
describe '-- when sent #header_set with a new header' do
|
|
1291
|
-
|
|
1292
|
-
|
|
1282
|
+
let :new_request do
|
|
1283
|
+
request.header_set 'foo', 'bar'
|
|
1293
1284
|
end
|
|
1294
1285
|
|
|
1295
1286
|
it 'should return a request with an unchanged URI' do
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1287
|
+
new_request.uri.should == URI.parse('https://' +
|
|
1288
|
+
'njonsson@github.com:123' +
|
|
1289
|
+
'/search/deep?q=http&lang=en' +
|
|
1290
|
+
'#content')
|
|
1300
1291
|
end
|
|
1301
1292
|
|
|
1302
1293
|
it 'should return a request with no response' do
|
|
1303
|
-
|
|
1294
|
+
new_request.response.should be_nil
|
|
1304
1295
|
end
|
|
1305
1296
|
|
|
1306
1297
|
describe '--' do
|
|
1307
1298
|
it 'should return a request with the header, plus the default ' +
|
|
1308
1299
|
'headers' do
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1300
|
+
new_request.headers.should == [['User-Agent', 'htty/' +
|
|
1301
|
+
HTTY::VERSION],
|
|
1302
|
+
['Authorization', 'Basic ' +
|
|
1303
|
+
'bmpvbnNzb24='],
|
|
1304
|
+
['foo', 'bar']]
|
|
1314
1305
|
end
|
|
1315
1306
|
|
|
1316
1307
|
it 'should return a request without a response' do
|
|
1317
|
-
|
|
1308
|
+
new_request.response.should be_nil
|
|
1318
1309
|
end
|
|
1319
1310
|
end
|
|
1320
1311
|
|
|
1321
1312
|
describe 'and then #header_unset' do
|
|
1322
1313
|
describe 'with the same header name --' do
|
|
1323
|
-
|
|
1324
|
-
|
|
1314
|
+
let :new_request do
|
|
1315
|
+
request.header_unset 'foo'
|
|
1325
1316
|
end
|
|
1326
1317
|
|
|
1327
1318
|
it 'should return a request with only the default headers' do
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1319
|
+
new_request.headers.should == [['User-Agent', 'htty/' +
|
|
1320
|
+
HTTY::VERSION],
|
|
1321
|
+
['Authorization', 'Basic ' +
|
|
1322
|
+
'bmpvbnNzb2' +
|
|
1323
|
+
'4=']]
|
|
1333
1324
|
end
|
|
1334
1325
|
end
|
|
1335
1326
|
end
|
|
1336
1327
|
|
|
1337
1328
|
describe 'and then #headers_unset_all --' do
|
|
1338
|
-
|
|
1339
|
-
|
|
1329
|
+
let :new_request do
|
|
1330
|
+
request.headers_unset_all
|
|
1340
1331
|
end
|
|
1341
1332
|
|
|
1342
1333
|
it 'should return a request with no headers' do
|
|
1343
|
-
|
|
1334
|
+
new_request.headers.should be_empty
|
|
1344
1335
|
end
|
|
1345
1336
|
end
|
|
1346
1337
|
end
|
|
1347
1338
|
|
|
1348
1339
|
describe '-- when sent #body_set with a body' do
|
|
1349
|
-
|
|
1350
|
-
|
|
1340
|
+
let :new_request do
|
|
1341
|
+
request.body_set 'foo'
|
|
1351
1342
|
end
|
|
1352
1343
|
|
|
1353
1344
|
it 'should return a request with an unchanged URI' do
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1345
|
+
new_request.uri.should == URI.parse('https://' +
|
|
1346
|
+
'njonsson@github.com:123' +
|
|
1347
|
+
'/search/deep?q=http&lang=en' +
|
|
1348
|
+
'#content')
|
|
1358
1349
|
end
|
|
1359
1350
|
|
|
1360
1351
|
it 'should return a request with no response' do
|
|
1361
|
-
|
|
1352
|
+
new_request.response.should be_nil
|
|
1362
1353
|
end
|
|
1363
1354
|
|
|
1364
1355
|
describe '--' do
|
|
1365
1356
|
it 'should return a request with the body' do
|
|
1366
|
-
|
|
1357
|
+
new_request.body.should == 'foo'
|
|
1367
1358
|
end
|
|
1368
1359
|
|
|
1369
1360
|
it 'should return a request with only the default headers' do
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1361
|
+
new_request.headers.should == [['User-Agent', 'htty/' +
|
|
1362
|
+
HTTY::VERSION],
|
|
1363
|
+
['Authorization', 'Basic ' +
|
|
1364
|
+
'bmpvbnNzb2' +
|
|
1365
|
+
'4=']]
|
|
1375
1366
|
end
|
|
1376
1367
|
|
|
1377
1368
|
it "should return a request with the expected 'Content-Length' " +
|
|
1378
1369
|
"header, plus the 'User-Agent' header if we do not exclude " +
|
|
1379
1370
|
"the 'Content-Length' header" do
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1371
|
+
new_request.headers(true).should == [['User-Agent', 'htty/' +
|
|
1372
|
+
HTTY::VERSION],
|
|
1373
|
+
['Authorization', 'Basic ' +
|
|
1374
|
+
'bmpvbn' +
|
|
1375
|
+
'Nzb24='],
|
|
1376
|
+
['Content-Length', '3']]
|
|
1386
1377
|
end
|
|
1387
1378
|
|
|
1388
1379
|
it 'should return a request without a response' do
|
|
1389
|
-
|
|
1380
|
+
new_request.response.should be_nil
|
|
1390
1381
|
end
|
|
1391
1382
|
end
|
|
1392
1383
|
|
|
1393
1384
|
describe 'and then #body_unset' do
|
|
1394
|
-
|
|
1395
|
-
|
|
1385
|
+
let :new_request do
|
|
1386
|
+
request.body_unset
|
|
1396
1387
|
end
|
|
1397
1388
|
|
|
1398
1389
|
it 'should return a request with no body' do
|
|
1399
|
-
|
|
1390
|
+
new_request.body.should be_nil
|
|
1400
1391
|
end
|
|
1401
1392
|
|
|
1402
1393
|
it 'should return a request with only the default headers' do
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1394
|
+
new_request.headers.should == [['User-Agent', 'htty/' +
|
|
1395
|
+
HTTY::VERSION],
|
|
1396
|
+
['Authorization', 'Basic ' +
|
|
1397
|
+
'bmpvbnNzb2' +
|
|
1398
|
+
'4=']]
|
|
1408
1399
|
end
|
|
1409
1400
|
end
|
|
1410
1401
|
end
|