htty 1.1.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/History.markdown +46 -0
  2. data/README.markdown +12 -12
  3. data/VERSION +1 -1
  4. data/lib/htty/cli.rb +10 -0
  5. data/lib/htty/cli/command.rb +50 -41
  6. data/lib/htty/cli/commands/http_put.rb +3 -0
  7. data/lib/htty/cli/commands/query_unset.rb +4 -2
  8. data/lib/htty/cli/http_method_command.rb +5 -3
  9. data/spec/integration/htty/cli/commands/query_add_spec.rb +51 -0
  10. data/spec/integration/htty/cli/commands/query_remove_spec.rb +37 -0
  11. data/spec/integration/htty/cli/commands/query_set_spec.rb +72 -0
  12. data/spec/integration/htty/cli/commands/query_unset_spec.rb +37 -0
  13. data/spec/unit/htty/cli/commands/address_spec.rb +103 -0
  14. data/spec/unit/htty/cli/commands/body_clear_spec.rb +64 -0
  15. data/spec/unit/htty/cli/commands/body_request_spec.rb +72 -0
  16. data/spec/unit/htty/cli/commands/body_response_spec.rb +70 -0
  17. data/spec/unit/htty/cli/commands/body_set_spec.rb +71 -0
  18. data/spec/unit/htty/cli/commands/body_unset_spec.rb +69 -0
  19. data/spec/unit/htty/cli/commands/cd_spec.rb +57 -0
  20. data/spec/unit/htty/cli/commands/cookie_add_spec.rb +64 -0
  21. data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +64 -0
  22. data/spec/unit/htty/cli/commands/cookies_add_spec.rb +78 -0
  23. data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +64 -0
  24. data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +73 -0
  25. data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +69 -0
  26. data/spec/unit/htty/cli/commands/cookies_spec.rb +76 -0
  27. data/spec/unit/htty/cli/commands/cookies_use_spec.rb +75 -0
  28. data/spec/unit/htty/cli/commands/delete_spec.rb +64 -0
  29. data/spec/unit/htty/cli/commands/exit_spec.rb +64 -0
  30. data/spec/unit/htty/cli/commands/follow_spec.rb +70 -0
  31. data/spec/unit/htty/cli/commands/form_add_spec.rb +64 -0
  32. data/spec/unit/htty/cli/commands/form_clear_spec.rb +64 -0
  33. data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +66 -0
  34. data/spec/unit/htty/cli/commands/form_remove_spec.rb +57 -0
  35. data/spec/unit/htty/cli/commands/form_spec.rb +57 -0
  36. data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +64 -0
  37. data/spec/unit/htty/cli/commands/fragment_set_spec.rb +73 -0
  38. data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +72 -0
  39. data/spec/unit/htty/cli/commands/get_spec.rb +64 -0
  40. data/spec/unit/htty/cli/commands/header_set_spec.rb +64 -0
  41. data/spec/unit/htty/cli/commands/header_unset_spec.rb +64 -0
  42. data/spec/unit/htty/cli/commands/headers_clear_spec.rb +64 -0
  43. data/spec/unit/htty/cli/commands/headers_request_spec.rb +81 -0
  44. data/spec/unit/htty/cli/commands/headers_response_spec.rb +77 -0
  45. data/spec/unit/htty/cli/commands/headers_set_spec.rb +74 -0
  46. data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +71 -0
  47. data/spec/unit/htty/cli/commands/headers_unset_spec.rb +63 -0
  48. data/spec/unit/htty/cli/commands/help_spec.rb +67 -0
  49. data/spec/unit/htty/cli/commands/history_spec.rb +65 -0
  50. data/spec/unit/htty/cli/commands/history_verbose_spec.rb +72 -0
  51. data/spec/unit/htty/cli/commands/host_set_spec.rb +71 -0
  52. data/spec/unit/htty/cli/commands/http_delete_spec.rb +73 -0
  53. data/spec/unit/htty/cli/commands/http_get_spec.rb +75 -0
  54. data/spec/unit/htty/cli/commands/http_head_spec.rb +69 -0
  55. data/spec/unit/htty/cli/commands/http_options_spec.rb +69 -0
  56. data/spec/unit/htty/cli/commands/http_post_spec.rb +71 -0
  57. data/spec/unit/htty/cli/commands/http_put_spec.rb +69 -0
  58. data/spec/unit/htty/cli/commands/http_trace_spec.rb +69 -0
  59. data/spec/unit/htty/cli/commands/path_set_spec.rb +72 -0
  60. data/spec/unit/htty/cli/commands/port_set_spec.rb +73 -0
  61. data/spec/unit/htty/cli/commands/post_spec.rb +64 -0
  62. data/spec/unit/htty/cli/commands/put_spec.rb +64 -0
  63. data/spec/unit/htty/cli/commands/query_add_spec.rb +67 -36
  64. data/spec/unit/htty/cli/commands/query_clear_spec.rb +64 -0
  65. data/spec/unit/htty/cli/commands/query_remove_spec.rb +69 -24
  66. data/spec/unit/htty/cli/commands/query_set_spec.rb +59 -49
  67. data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +73 -0
  68. data/spec/unit/htty/cli/commands/query_unset_spec.rb +75 -0
  69. data/spec/unit/htty/cli/commands/quit_spec.rb +64 -0
  70. data/spec/unit/htty/cli/commands/reuse_spec.rb +72 -0
  71. data/spec/unit/htty/cli/commands/scheme_set_spec.rb +74 -0
  72. data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +67 -0
  73. data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +60 -0
  74. data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +65 -0
  75. data/spec/unit/htty/cli/commands/status_spec.rb +73 -0
  76. data/spec/unit/htty/cli/commands/undo_spec.rb +57 -0
  77. data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +64 -0
  78. data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +75 -0
  79. data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +72 -0
  80. data/spec/unit/htty/cli_spec.rb +8 -2
  81. data/spec/unit/htty/ordered_hash_spec.rb +14 -24
  82. data/spec/unit/htty/preferences_spec.rb +1 -1
  83. data/spec/unit/htty/request_spec.rb +454 -463
  84. 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 be_equal(HTTY::Preferences.current)
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
- @request.headers.should == [['User-Agent', "htty/#{HTTY::VERSION}"]]
8
+ request.headers.should == [['User-Agent', "htty/#{HTTY::VERSION}"]]
9
9
  end
10
10
 
11
11
  it 'should have no body' do
12
- @request.body.should be_nil
12
+ request.body.should be_nil
13
13
  end
14
14
 
15
15
  it 'should have no response' do
16
- @request.response.should be_nil
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
- @request.headers.should == [['User-Agent', "htty/#{HTTY::VERSION}"],
23
- ['Authorization', 'Basic bmpvbnNzb24=']]
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
- @request.body.should be_nil
27
+ request.body.should be_nil
28
28
  end
29
29
 
30
30
  it 'should have no response' do
31
- @request.response.should be_nil
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
- before :each do
90
- @request = HTTY::Request.new(nil)
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
- @request.uri.should == URI.parse('http://0.0.0.0:80/')
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
- before :each do
102
- @request = HTTY::Request.new('')
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
- @request.uri.should == URI.parse('http://0.0.0.0:80/')
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
- before :each do
115
- @request = HTTY::Request.new('127.0.0.1')
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
- @request.uri.should == URI.parse('http://127.0.0.1:80/')
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
- before :each do
127
- @request = HTTY::Request.new('localhost')
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
- @request.uri.should == URI.parse('http://localhost:80/')
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
- @request.query_set 'foo', 'bar'
131
+ request.query_set 'foo', 'bar'
140
132
  end
141
133
 
142
134
  it 'should have a URI including the query parameter' do
143
- @request.uri.should == URI.parse('http://localhost:80/?foo=bar')
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
- before :each do
153
- @request = HTTY::Request.new('localhost:8080')
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
- @request.uri.should == URI.parse('http://localhost:8080/')
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
- before :each do
165
- @request = HTTY::Request.new('http://localhost')
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
- @request.uri.should == URI.parse('http://localhost:80/')
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
- before :each do
177
- @request = HTTY::Request.new('https://njonsson@github.com')
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
- @request.uri.should == URI.parse('https://njonsson@github.com:443/')
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
- before :each do
189
- @request = HTTY::Request.new('github.com/')
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
- @request.uri.should == URI.parse('http://github.com:80/')
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
- before :each do
201
- @request = HTTY::Request.new('github.com:443/')
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
- @request.uri.should == URI.parse('https://github.com:443/')
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
- before :each do
213
- @request = HTTY::Request.new('http://github.com:443/')
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
- @request.uri.should == URI.parse('http://github.com:443/')
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
- before :each do
225
- @request = HTTY::Request.new('github.com/explore')
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
- @request.uri.should == URI.parse('http://github.com:80/explore')
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
- before :each do
237
- @request = HTTY::Request.new('github.com?search=http')
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
- @request.uri.should == URI.parse('http://github.com:80/?search=http')
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
- before :each do
250
- @request = HTTY::Request.new('github.com/search?q=http&lang=en')
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
- @request.uri.should == URI.parse('http://github.com:80' +
256
- '/search?q=http&lang=en')
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
- before :each do
264
- @request = HTTY::Request.new('github.com/explore#trending')
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
- @request.uri.should == URI.parse('http://github.com:80' +
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
- before :each do
278
- @request = HTTY::Request.new('github.com:123/search/deep' +
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
- @request.uri.should == URI.parse('http://github.com:123' +
285
- '/search/deep?q=http&lang=en' +
286
- '#content')
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
- before :each do
295
- @request = HTTY::Request.new('https://njonsson@github.com:123' +
296
- '/search/deep?q=http&lang=en#content')
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
- @request.response.should be_nil
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
- @request.uri.should == URI.parse('https://njonsson@github.com:123' +
309
- '/search/deep?q=http&lang=en' +
310
- '#content')
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
- @request.address 'http://steve@mac.com:456/archives/2010' +
321
- '?author=jobs&subject=html5#flames'
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
- @request.uri.should == URI.parse('http://steve@mac.com:456' +
328
- '/archives/2010' +
329
- '?author=jobs&subject=html5' +
330
- '#flames')
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
- @request.headers.should == [['User-Agent', 'htty/' +
336
- HTTY::VERSION],
337
- ['Authorization', 'Basic c3RldmU=']]
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
- @request.body.should be_nil
331
+ request.body.should be_nil
342
332
  end
343
333
 
344
334
  it 'should have no response' do
345
- @request.response.should be_nil
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
- @request.address 'mac.com'
341
+ request.address 'mac.com'
352
342
  end
353
343
 
354
344
  it 'should have an HTTP URI for the new host' do
355
- @request.uri.should == URI.parse('http://mac.com:80/')
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
- @request.scheme_set 'https'
355
+ request.scheme_set 'https'
366
356
  end
367
357
 
368
358
  it 'should have an unchanged URI' do
369
- @request.uri.should == URI.parse('https://njonsson@github.com' +
370
- ':123' +
371
- '/search/deep?q=http&lang=en' +
372
- '#content')
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
- @request.scheme_set 'http'
370
+ request.scheme_set 'http'
381
371
  end
382
372
 
383
373
  it 'should have the same URI, with the changed scheme' do
384
- @request.uri.should == URI.parse('http://njonsson@github.com' +
385
- ':123' +
386
- '/search/deep?q=http&lang=en' +
387
- '#content')
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
- @request.userinfo_set 'njonsson'
387
+ request.userinfo_set 'njonsson'
398
388
  end
399
389
 
400
390
  it 'should have an unchanged URI' do
401
- @request.uri.should == URI.parse('https://njonsson@github.com' +
402
- ':123' +
403
- '/search/deep?q=http&lang=en' +
404
- '#content')
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
- @request.userinfo_set 'nils'
403
+ request.userinfo_set 'nils'
414
404
  end
415
405
 
416
406
  it 'should have the same URI, with the changed userinfo' do
417
- @request.uri.should == URI.parse('https://nils@github.com:123' +
418
- '/search/deep?q=http&lang=en' +
419
- '#content')
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
- @request.headers.should == [['User-Agent', 'htty/' +
425
- HTTY::VERSION],
426
- ['Authorization', 'Basic bmlscw==']]
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
- @request.body.should be_nil
420
+ request.body.should be_nil
431
421
  end
432
422
 
433
423
  it 'should have no response' do
434
- @request.response.should be_nil
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
- @request.userinfo_set 'n%45'
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
- @request.uri.should == URI.parse('https://n%45@github.com:123' +
445
- '/search/deep?q=http&lang=en' +
446
- '#content')
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
- @request.headers.should == [['User-Agent', 'htty/' +
452
- HTTY::VERSION],
453
- ['Authorization', 'Basic bkU=']]
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
- @request.body.should be_nil
447
+ request.body.should be_nil
458
448
  end
459
449
 
460
450
  it 'should have no response' do
461
- @request.response.should be_nil
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
- @request.userinfo_unset
459
+ request.userinfo_unset
470
460
  end
471
461
 
472
462
  it 'should have the same URI, without userinfo' do
473
- @request.uri.should == URI.parse('https://github.com:123' +
474
- '/search/deep?q=http&lang=en' +
475
- '#content')
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
- @request.host_set 'github.com'
474
+ request.host_set 'github.com'
485
475
  end
486
476
 
487
477
  it 'should have an unchanged URI' do
488
- @request.uri.should == URI.parse('https://njonsson@github.com' +
489
- ':123' +
490
- '/search/deep?q=http&lang=en' +
491
- '#content')
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
- @request.host_set 'gist.github.com'
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
- @request.uri.should == URI.parse('https://' +
504
- 'njonsson@gist.github.com:123' +
505
- '/search/deep?q=http&lang=en' +
506
- '#content')
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
- @request.port_set 123
506
+ request.port_set 123
517
507
  end
518
508
 
519
509
  it 'should have an unchanged URI' do
520
- @request.uri.should == URI.parse('https://njonsson@github.com' +
521
- ':123' +
522
- '/search/deep?q=http&lang=en' +
523
- '#content')
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
- @request.port_set 8888
521
+ request.port_set 8888
532
522
  end
533
523
 
534
524
  it 'should have the same URI, with the changed scheme' do
535
- @request.uri.should == URI.parse('https://njonsson@github.com' +
536
- ':8888' +
537
- '/search/deep?q=http&lang=en' +
538
- '#content')
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
- @request.path_set 'foo'
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
- @request.uri.should == URI.parse('https://njonsson@github.com' +
553
- ':123' +
554
- '/search/deep/foo' +
555
- '?q=http&lang=en#content')
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
- @request.path_set '..'
553
+ request.path_set '..'
564
554
  end
565
555
 
566
556
  it 'should have the same URI, ascending to the expected path' do
567
- @request.uri.should == URI.parse('https://njonsson@github.com' +
568
- ':123' +
569
- '/search?q=http&lang=en#content')
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
- @request.path_set '/foo/bar'
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
- @request.uri.should == URI.parse('https://njonsson@github.com' +
582
- ':123' +
583
- '/foo/bar?q=http&lang=en' +
584
- '#content')
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
- @request.query_set 'foo', 'bar'
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
- @request.uri.should == URI.parse('https://njonsson@github.com' +
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
- @request.query_set 'q', 'ruby'
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
- @request.uri.should == URI.parse('https://njonsson@github.com' +
615
- ':123' +
616
- '/search/deep?q=ruby&lang=en' +
617
- '#content')
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
- @request.query_set 'lang', 'fr'
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
- @request.uri.should == URI.parse('https://njonsson@github.com' +
631
- ':123' +
632
- '/search/deep?q=http&lang=fr' +
633
- '#content')
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
- @request.query_unset 'fizzle'
633
+ request.query_unset 'fizzle'
644
634
  end
645
635
 
646
636
  it 'should have an unchanged URI' do
647
- @request.uri.should == URI.parse('https://njonsson@github.com' +
648
- ':123' +
649
- '/search/deep?q=http&lang=en' +
650
- '#content')
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
- @request.query_unset 'q'
648
+ request.query_unset 'q'
659
649
  end
660
650
 
661
651
  it 'should have a URI missing the first query parameter' do
662
- @request.uri.should == URI.parse('https://njonsson@github.com' +
663
- ':123' +
664
- '/search/deep?lang=en#content')
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
- @request.query_unset 'lang'
662
+ request.query_unset 'lang'
673
663
  end
674
664
 
675
665
  it 'should have a URI missing the second query parameter' do
676
- @request.uri.should == URI.parse('https://njonsson@github.com' +
677
- ':123' +
678
- '/search/deep?q=http#content')
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
- @request.query_unset_all
677
+ request.query_unset_all
688
678
  end
689
679
 
690
680
  it 'should have a URI having no query string' do
691
- @request.uri.should == URI.parse('https://njonsson@github.com:123' +
692
- '/search/deep#content')
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
- @request.fragment_set 'content'
691
+ request.fragment_set 'content'
702
692
  end
703
693
 
704
694
  it 'should have an unchanged URI' do
705
- @request.uri.should == URI.parse('https://njonsson@github.com' +
706
- ':123' +
707
- '/search/deep?q=http&lang=en' +
708
- '#content')
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
- @request.fragment_set 'details'
706
+ request.fragment_set 'details'
717
707
  end
718
708
 
719
709
  it 'should have the same URI, with the changed fragment' do
720
- @request.uri.should == URI.parse('https://njonsson@github.com' +
721
- ':123' +
722
- '/search/deep?q=http&lang=en' +
723
- '#details')
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
- @request.fragment_unset
722
+ request.fragment_unset
733
723
  end
734
724
 
735
725
  it 'should have the same URI, without fragment' do
736
- @request.uri.should == URI.parse('https://njonsson@github.com:123' +
737
- '/search/deep?q=http&lang=en')
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
- @request.header_set 'foo', 'bar'
735
+ request.header_set 'foo', 'bar'
746
736
  end
747
737
 
748
738
  it 'should have an unchanged URI' do
749
- @request.uri.should == URI.parse('https://njonsson@github.com:123' +
750
- '/search/deep?q=http&lang=en' +
751
- '#content')
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
- @request.headers.should == [['User-Agent', 'htty/' +
757
- HTTY::VERSION],
758
- ['Authorization', 'Basic ' +
759
- 'bmpvbnNzb24='],
760
- ['foo', 'bar']]
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
- @request.header_unset 'foo'
757
+ request.header_unset 'foo'
768
758
  end
769
759
 
770
760
  it 'should have only the default headers' do
771
- @request.headers.should == [['User-Agent', 'htty/' +
772
- HTTY::VERSION],
773
- ['Authorization', 'Basic ' +
774
- 'bmpvbnNzb24=']]
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
- @request.header_unset 'qux'
770
+ request.header_unset 'qux'
781
771
  end
782
772
 
783
773
  it 'should have the header, plus the default headers' do
784
- @request.headers.should == [['User-Agent', 'htty/' +
785
- HTTY::VERSION],
786
- ['Authorization', 'Basic ' +
787
- 'bmpvbnNzb24='],
788
- ['foo', 'bar']]
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
- @request.headers_unset_all
785
+ request.headers_unset_all
796
786
  end
797
787
 
798
788
  it 'should have no headers' do
799
- @request.headers.should be_empty
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
- @request.cookie_add 'foo', 'bar'
796
+ request.cookie_add 'foo', 'bar'
807
797
  end
808
798
 
809
799
  it 'should have an unchanged URI' do
810
- @request.uri.should == URI.parse('https://njonsson@github.com:123' +
811
- '/search/deep?q=http&lang=en' +
812
- '#content')
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
- @request.cookies.should == [%w(foo bar)]
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
- @request.headers.should == [['User-Agent', 'htty/' +
822
- HTTY::VERSION],
823
- ['Authorization', 'Basic ' +
824
- 'bmpvbnNzb24='],
825
- ['Cookie', 'foo=bar']]
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
- @request.cookie_add 'foo', 'qux'
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
- @request.cookies.should == [%w(foo bar), %w(foo qux)]
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
- @request.headers.should == [['User-Agent', 'htty/' +
842
- HTTY::VERSION],
843
- ['Authorization', 'Basic ' +
844
- 'bmpvbnNzb24='],
845
- ['Cookie', 'foo=bar; ' +
846
- 'foo=qux']]
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
- @request.cookie_add 'baz', 'qux'
842
+ request.cookie_add 'baz', 'qux'
853
843
  end
854
844
 
855
845
  it 'should have the new cookie' do
856
- @request.cookies.should == [%w(foo bar), %w(baz qux)]
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
- @request.headers.should == [['User-Agent', 'htty/' +
862
- HTTY::VERSION],
863
- ['Authorization', 'Basic ' +
864
- 'bmpvbnNzb24='],
865
- ['Cookie', 'foo=bar; ' +
866
- 'baz=qux']]
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
- @request.cookie_add 'baz'
862
+ request.cookie_add 'baz'
873
863
  end
874
864
 
875
865
  it 'should have the new cookie' do
876
- @request.cookies.should == [['foo', 'bar'], ['baz', nil]]
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
- @request.headers.should == [['User-Agent', 'htty/' +
882
- HTTY::VERSION],
883
- ['Authorization', 'Basic ' +
884
- 'bmpvbnNzb24='],
885
- ['Cookie', 'foo=bar; baz']]
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
- @request.cookie_remove 'foo'
883
+ request.cookie_remove 'foo'
894
884
  end
895
885
 
896
886
  it 'should have no cookie' do
897
- @request.cookies.should be_empty
887
+ request.cookies.should be_empty
898
888
  end
899
889
 
900
890
  it 'should have only the default headers' do
901
- @request.headers.should == [['User-Agent', 'htty/' +
902
- HTTY::VERSION],
903
- ['Authorization', 'Basic ' +
904
- 'bmpvbnNzb24=']]
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
- @request.cookie_remove 'qux'
900
+ request.cookie_remove 'qux'
911
901
  end
912
902
 
913
903
  it 'should have the cookie' do
914
- @request.cookies.should == [%w(foo bar)]
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
- @request.headers.should == [['User-Agent', 'htty/' +
919
- HTTY::VERSION],
920
- ['Authorization', 'Basic ' +
921
- 'bmpvbnNzb24='],
922
- ['Cookie', 'foo=bar']]
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
- @request.cookies_remove_all
919
+ request.cookies_remove_all
930
920
  end
931
921
 
932
922
  it 'should have no cookies' do
933
- @request.cookies.should be_empty
923
+ request.cookies.should be_empty
934
924
  end
935
925
 
936
926
  it 'should have only the default headers' do
937
- @request.headers.should == [['User-Agent', 'htty/' +
938
- HTTY::VERSION],
939
- ['Authorization', 'Basic ' +
940
- 'bmpvbnNzb24=']]
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
- @request.address 'http://github.com'
937
+ request.address 'http://github.com'
948
938
  end
949
939
 
950
940
  it 'should have the cookie' do
951
- @request.cookies.should == [%w(foo bar)]
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
- @request.headers.should == [['User-Agent', 'htty/' +
956
- HTTY::VERSION],
957
- ['Cookie', 'foo=bar']]
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
- @request.address 'http://google.com'
953
+ request.address 'http://google.com'
964
954
  end
965
955
 
966
956
  it 'should have no cookies' do
967
- @request.cookies.should == []
968
- @request.cookies.should be_empty
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
- @request.headers.should == [['User-Agent',
973
- "htty/#{HTTY::VERSION}"]]
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
- @request.cookie_add 'foo', 'bar=baz=qux'
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
- @request.cookies.should == [%w(foo bar=baz=qux)]
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
- @request.headers.should == [['User-Agent', 'htty/' +
991
- HTTY::VERSION],
992
- ['Authorization', 'Basic ' +
993
- 'bmpvbnNzb24='],
994
- ['Cookie', 'foo=bar=baz=qux']]
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
- @request.body_set 'foo'
991
+ request.body_set 'foo'
1002
992
  end
1003
993
 
1004
994
  it 'should have an unchanged URI' do
1005
- @request.uri.should == URI.parse('https://njonsson@github.com:123' +
1006
- '/search/deep?q=http&lang=en' +
1007
- '#content')
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
- @request.body.should == 'foo'
1002
+ request.body.should == 'foo'
1013
1003
  end
1014
1004
 
1015
1005
  it 'should have only the default headers' do
1016
- @request.headers.should == [['User-Agent', 'htty/' +
1017
- HTTY::VERSION],
1018
- ['Authorization', 'Basic ' +
1019
- 'bmpvbnNzb24=']]
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
- @request.headers(true).should == [['User-Agent', 'htty/' +
1026
- HTTY::VERSION],
1027
- ['Authorization', 'Basic ' +
1028
- 'bmpvbnNz' +
1029
- 'b24='],
1030
- ['Content-Length', '3']]
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
- @request.body_unset
1026
+ request.body_unset
1037
1027
  end
1038
1028
 
1039
1029
  it 'should have no body' do
1040
- @request.body.should be_nil
1030
+ request.body.should be_nil
1041
1031
  end
1042
1032
 
1043
1033
  it 'should have only the default headers' do
1044
- @request.headers.should == [['User-Agent', 'htty/' +
1045
- HTTY::VERSION],
1046
- ['Authorization', 'Basic ' +
1047
- 'bmpvbnNzb24=']]
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
- @response = HTTY::Response.new
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
- @request.uri.should == URI.parse('https://njonsson@github.com:123' +
1061
- '/search/deep?q=http&lang=en' +
1062
- '#content')
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
- @request.headers.should == [['User-Agent', 'htty/' +
1067
- HTTY::VERSION],
1068
- ['Authorization', 'Basic ' +
1069
- 'bmpvbnNzb24=']]
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
- @request.body.should be_nil
1066
+ request.body.should be_nil
1074
1067
  end
1075
1068
 
1076
1069
  it 'should not affect the response' do
1077
- @request.response.should == @response
1070
+ request.response.should == response
1078
1071
  end
1079
1072
 
1080
1073
  describe '-- when sent #address with a different hostname --' do
1081
- before :each do
1082
- @new_request = @request.address('mac.com')
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
- @new_request.uri.should == URI.parse('http://mac.com:80/')
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
- @new_request.response.should be_nil
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
- before :each do
1096
- @new_request = @request.scheme_set('http')
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
- @new_request.uri.should == URI.parse('http://njonsson@github.com' +
1102
- ':123' +
1103
- '/search/deep?q=http&lang=en' +
1104
- '#content')
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
- @new_request.response.should be_nil
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
- before :each do
1114
- @new_request = @request.userinfo_set('nils')
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
- @new_request.uri.should == URI.parse('https://nils@github.com' +
1120
- ':123' +
1121
- '/search/deep' +
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
- @new_request.response.should be_nil
1118
+ new_request.response.should be_nil
1128
1119
  end
1129
1120
  end
1130
1121
 
1131
1122
  describe '-- when sent #userinfo_unset --' do
1132
- before :each do
1133
- @new_request = @request.userinfo_unset
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
- @new_request.uri.should == URI.parse('https://github.com:123' +
1138
- '/search/deep?q=http&lang=en' +
1139
- '#content')
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
- @new_request.response.should be_nil
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
- before :each do
1149
- @new_request = @request.host_set('gist.github.com')
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
- @new_request.uri.should == URI.parse('https://' +
1155
- 'njonsson@gist.github.com' +
1156
- ':123' +
1157
- '/search/deep?q=http&lang=en' +
1158
- '#content')
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
- @new_request.response.should be_nil
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
- before :each do
1168
- @new_request = @request.port_set(8888)
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
- @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1174
- ':8888' +
1175
- '/search/deep?q=http&lang=en' +
1176
- '#content')
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
- @new_request.response.should be_nil
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
- before :each do
1186
- @new_request = @request.path_set('foo')
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
- @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1192
- ':123' +
1193
- '/search/deep/foo' +
1194
- '?q=http&lang=en#content')
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
- @new_request.response.should be_nil
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
- before :each do
1204
- @new_request = @request.query_set('foo', 'bar')
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
- @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1210
- ':123' +
1211
- '/search/deep' +
1212
- '?q=http&lang=en&foo=bar' +
1213
- '#content')
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
- @new_request.response.should be_nil
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
- before :each do
1224
- @new_request = @request.query_unset('q')
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
- @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1230
- ':123' +
1231
- '/search/deep?lang=en#content')
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
- @new_request.response.should be_nil
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
- before :each do
1241
- @new_request = @request.query_unset_all
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
- @new_request.uri.should == URI.parse('https://' +
1247
- 'njonsson@github.com:123' +
1248
- '/search/deep#content')
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
- @new_request.response.should be_nil
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
- before :each do
1258
- @new_request = @request.fragment_set('details')
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
- @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1264
- ':123' +
1265
- '/search/deep?q=http&lang=en' +
1266
- '#details')
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
- @new_request.response.should be_nil
1261
+ new_request.response.should be_nil
1271
1262
  end
1272
1263
  end
1273
1264
 
1274
1265
  describe '-- when sent #fragment_unset --' do
1275
- before :each do
1276
- @new_request = @request.fragment_unset
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
- @new_request.uri.should == URI.parse('https://' +
1281
- 'njonsson@github.com:123' +
1282
- '/search/deep?q=http&lang=en')
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
- @new_request.response.should be_nil
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
- before :each do
1292
- @new_request = @request.header_set('foo', 'bar')
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
- @new_request.uri.should == URI.parse('https://' +
1297
- 'njonsson@github.com:123' +
1298
- '/search/deep?q=http&lang=en' +
1299
- '#content')
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
- @new_request.response.should be_nil
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
- @new_request.headers.should == [['User-Agent', 'htty/' +
1310
- HTTY::VERSION],
1311
- ['Authorization', 'Basic ' +
1312
- 'bmpvbnNzb24='],
1313
- ['foo', 'bar']]
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
- @new_request.response.should be_nil
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
- before :each do
1324
- @new_request = @request.header_unset('foo')
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
- @new_request.headers.should == [['User-Agent', 'htty/' +
1329
- HTTY::VERSION],
1330
- ['Authorization', 'Basic ' +
1331
- 'bmpvbnNzb2' +
1332
- '4=']]
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
- before :each do
1339
- @new_request = @request.headers_unset_all
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
- @new_request.headers.should be_empty
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
- before :each do
1350
- @new_request = @request.body_set('foo')
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
- @new_request.uri.should == URI.parse('https://' +
1355
- 'njonsson@github.com:123' +
1356
- '/search/deep?q=http&lang=en' +
1357
- '#content')
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
- @new_request.response.should be_nil
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
- @new_request.body.should == 'foo'
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
- @new_request.headers.should == [['User-Agent', 'htty/' +
1371
- HTTY::VERSION],
1372
- ['Authorization', 'Basic ' +
1373
- 'bmpvbnNzb2' +
1374
- '4=']]
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
- @new_request.headers(true).should == [['User-Agent', 'htty/' +
1381
- HTTY::VERSION],
1382
- ['Authorization', 'Basic ' +
1383
- 'bmpvbn' +
1384
- 'Nzb24='],
1385
- ['Content-Length', '3']]
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
- @new_request.response.should be_nil
1380
+ new_request.response.should be_nil
1390
1381
  end
1391
1382
  end
1392
1383
 
1393
1384
  describe 'and then #body_unset' do
1394
- before :each do
1395
- @new_request = @request.body_unset
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
- @new_request.body.should be_nil
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
- @new_request.headers.should == [['User-Agent', 'htty/' +
1404
- HTTY::VERSION],
1405
- ['Authorization', 'Basic ' +
1406
- 'bmpvbnNzb2' +
1407
- '4=']]
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