impuri 0.10.0 → 0.12.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.
@@ -4,902 +4,939 @@ gem 'minitest'
4
4
 
5
5
  $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')))
6
6
 
7
- require 'ImpURI'
7
+ require 'impuri'
8
8
  require 'minitest/autorun'
9
9
 
10
10
  describe ImpURI do
11
-
12
11
  describe 'attribute readers' do
13
-
14
12
  describe 'a very simple http URI' do
15
-
16
- before do
17
- @impuri = ImpURI.new('http://example.com')
18
- end
13
+ let(:impuri){ImpURI.new('http://example.com')}
19
14
 
20
15
  it 'must parse out the scheme' do
21
- _(@impuri.scheme).must_equal 'http'
22
- _(@impuri.protocol).must_equal 'http'
23
- _(@impuri.scheme_name).must_equal 'http'
16
+ _(impuri.scheme).must_equal 'http'
17
+ _(impuri.protocol).must_equal 'http'
18
+ _(impuri.scheme_name).must_equal 'http'
24
19
  end
25
20
 
26
21
  it 'must parse out the domain name' do
27
- _(@impuri.hostname).must_equal 'example.com'
28
- _(@impuri.host).must_equal 'example.com'
22
+ _(impuri.hostname).must_equal 'example.com'
23
+ _(impuri.host).must_equal 'example.com'
29
24
  end
30
25
 
31
26
  it 'must return nil if there is no path' do
32
- _(@impuri.path).must_be_nil
27
+ _(impuri.path).must_be_nil
33
28
  end
34
29
 
35
30
  it 'must return nil if there are no GET request parameters' do
36
- _(@impuri.parameter_string).must_be_nil
37
- _(@impuri.parameters).must_be_nil
31
+ _(impuri.parameter_string).must_be_nil
32
+ _(impuri.parameters).must_be_nil
38
33
  end
39
34
 
40
35
  it 'must return false for has_userinfo?()' do
41
- _(@impuri.has_userinfo?).must_equal false
42
- _(@impuri.has_credentials?).must_equal false
43
- _(@impuri.has_username_and_password?).must_equal false
44
- _(@impuri.has_user_info?).must_equal false
36
+ _(impuri.has_userinfo?).must_equal false
37
+ _(impuri.has_credentials?).must_equal false
38
+ _(impuri.has_username_and_password?).must_equal false
39
+ _(impuri.has_user_info?).must_equal false
45
40
  end
46
41
 
47
42
  it 'must return true for has_scheme?()' do
48
- _(@impuri.has_scheme?).must_equal true
49
- _(@impuri.has_protocol?).must_equal true
50
- _(@impuri.has_scheme_name?).must_equal true
51
- _(@impuri.scheme?).must_equal true
52
- _(@impuri.protocol?).must_equal true
53
- _(@impuri.scheme_name?).must_equal true
43
+ _(impuri.has_scheme?).must_equal true
44
+ _(impuri.has_protocol?).must_equal true
45
+ _(impuri.has_scheme_name?).must_equal true
46
+ _(impuri.scheme?).must_equal true
47
+ _(impuri.protocol?).must_equal true
48
+ _(impuri.scheme_name?).must_equal true
54
49
  end
55
50
 
56
51
  it 'must return false for has_colon_path_separator?()' do
57
- _(@impuri.has_colon_path_separator?).must_equal false
58
- _(@impuri.uses_colon_path_separator?).must_equal false
52
+ _(impuri.has_colon_path_separator?).must_equal false
53
+ _(impuri.uses_colon_path_separator?).must_equal false
59
54
  end
60
55
 
61
56
  it 'must return false for has_port_number?()' do
62
- _(@impuri.has_port_number?).must_equal false
63
- _(@impuri.has_port?).must_equal false
64
- _(@impuri.has_portnumber?).must_equal false
65
- _(@impuri.port_number?).must_equal false
66
- _(@impuri.port?).must_equal false
67
- _(@impuri.portnumber?).must_equal false
57
+ _(impuri.has_port_number?).must_equal false
58
+ _(impuri.has_port?).must_equal false
59
+ _(impuri.has_portnumber?).must_equal false
60
+ _(impuri.port_number?).must_equal false
61
+ _(impuri.port?).must_equal false
62
+ _(impuri.portnumber?).must_equal false
68
63
  end
69
64
 
70
65
  it 'must return nil if there is no request URI' do
71
- _(@impuri.request_uri).must_be_nil
66
+ _(impuri.request_uri).must_be_nil
72
67
  end
73
68
  end # describe 'a very simple http URI'
74
69
 
75
70
  describe 'an http URI with a port number' do
76
- before do
77
- @impuri = ImpURI.new('http://example.com:8080')
78
- end
71
+ let(:impuri){ImpURI.new('http://example.com:8080')}
79
72
 
80
73
  it 'must parse out the scheme' do
81
- _(@impuri.scheme).must_equal 'http'
82
- _(@impuri.protocol).must_equal 'http'
83
- _(@impuri.scheme_name).must_equal 'http'
74
+ _(impuri.scheme).must_equal 'http'
75
+ _(impuri.protocol).must_equal 'http'
76
+ _(impuri.scheme_name).must_equal 'http'
84
77
  end
85
78
 
86
79
  it 'must parse out the domain name' do
87
- _(@impuri.hostname).must_equal 'example.com'
88
- _(@impuri.host).must_equal 'example.com'
80
+ _(impuri.hostname).must_equal 'example.com'
81
+ _(impuri.host).must_equal 'example.com'
89
82
  end
90
83
 
91
84
  it 'must return nil if there is no path' do
92
- _(@impuri.path).must_be_nil
85
+ _(impuri.path).must_be_nil
93
86
  end
94
87
 
95
88
  it 'must parse out the port number' do
96
- _(@impuri.port).must_equal '8080'
97
- _(@impuri.portnumber).must_equal '8080'
98
- _(@impuri.port_number).must_equal '8080'
89
+ _(impuri.port).must_equal '8080'
90
+ _(impuri.portnumber).must_equal '8080'
91
+ _(impuri.port_number).must_equal '8080'
99
92
  end
100
93
 
101
94
  it 'must return nil if there are no GET request parameters' do
102
- _(@impuri.parameter_string).must_be_nil
103
- _(@impuri.parameters).must_be_nil
95
+ _(impuri.parameter_string).must_be_nil
96
+ _(impuri.parameters).must_be_nil
104
97
  end
105
98
 
106
99
  it 'must return false for has_userinfo?()' do
107
- _(@impuri.has_userinfo?).must_equal false
108
- _(@impuri.has_credentials?).must_equal false
109
- _(@impuri.has_username_and_password?).must_equal false
110
- _(@impuri.has_user_info?).must_equal false
100
+ _(impuri.has_userinfo?).must_equal false
101
+ _(impuri.has_credentials?).must_equal false
102
+ _(impuri.has_username_and_password?).must_equal false
103
+ _(impuri.has_user_info?).must_equal false
111
104
  end
112
105
 
113
106
  it 'must return true for has_scheme?()' do
114
- _(@impuri.has_scheme?).must_equal true
115
- _(@impuri.has_protocol?).must_equal true
116
- _(@impuri.has_scheme_name?).must_equal true
117
- _(@impuri.scheme?).must_equal true
118
- _(@impuri.protocol?).must_equal true
119
- _(@impuri.scheme_name?).must_equal true
107
+ _(impuri.has_scheme?).must_equal true
108
+ _(impuri.has_protocol?).must_equal true
109
+ _(impuri.has_scheme_name?).must_equal true
110
+ _(impuri.scheme?).must_equal true
111
+ _(impuri.protocol?).must_equal true
112
+ _(impuri.scheme_name?).must_equal true
120
113
  end
121
114
 
122
115
  it 'must return false for has_colon_path_separator?()' do
123
- _(@impuri.has_colon_path_separator?).must_equal false
124
- _(@impuri.uses_colon_path_separator?).must_equal false
116
+ _(impuri.has_colon_path_separator?).must_equal false
117
+ _(impuri.uses_colon_path_separator?).must_equal false
125
118
  end
126
119
 
127
120
  it 'must return true for has_port_number?()' do
128
- _(@impuri.has_port_number?).must_equal true
129
- _(@impuri.has_port?).must_equal true
130
- _(@impuri.has_portnumber?).must_equal true
131
- _(@impuri.port_number?).must_equal true
132
- _(@impuri.port?).must_equal true
133
- _(@impuri.portnumber?).must_equal true
121
+ _(impuri.has_port_number?).must_equal true
122
+ _(impuri.has_port?).must_equal true
123
+ _(impuri.has_portnumber?).must_equal true
124
+ _(impuri.port_number?).must_equal true
125
+ _(impuri.port?).must_equal true
126
+ _(impuri.portnumber?).must_equal true
134
127
  end
135
128
 
136
129
  it 'must return nil if there is no request URI' do
137
- _(@impuri.request_uri).must_be_nil
130
+ _(impuri.request_uri).must_be_nil
138
131
  end
139
132
  end # describe 'an http URI with a port number'
140
133
 
141
134
  describe 'an http URI with a path' do
142
- before do
143
- @impuri = ImpURI.new('http://example.com/path/to/resource')
144
- end
135
+ let(:impuri){ImpURI.new('http://example.com/path/to/resource')}
145
136
 
146
137
  it 'must parse out the scheme' do
147
- _(@impuri.scheme).must_equal 'http'
148
- _(@impuri.protocol).must_equal 'http'
149
- _(@impuri.scheme_name).must_equal 'http'
138
+ _(impuri.scheme).must_equal 'http'
139
+ _(impuri.protocol).must_equal 'http'
140
+ _(impuri.scheme_name).must_equal 'http'
150
141
  end
151
142
 
152
143
  it 'must parse out the domain name' do
153
- _(@impuri.hostname).must_equal 'example.com'
154
- _(@impuri.host).must_equal 'example.com'
144
+ _(impuri.hostname).must_equal 'example.com'
145
+ _(impuri.host).must_equal 'example.com'
155
146
  end
156
147
 
157
148
  it 'must parse out the path' do
158
- _(@impuri.path).must_equal '/path/to/resource'
149
+ _(impuri.path).must_equal '/path/to/resource'
159
150
  end
160
151
 
161
152
  it 'must return nil if there are no GET request parameters' do
162
- _(@impuri.parameter_string).must_be_nil
163
- _(@impuri.parameters).must_be_nil
153
+ _(impuri.parameter_string).must_be_nil
154
+ _(impuri.parameters).must_be_nil
164
155
  end
165
156
 
166
157
  it 'must return false for has_userinfo?()' do
167
- _(@impuri.has_userinfo?).must_equal false
168
- _(@impuri.has_credentials?).must_equal false
169
- _(@impuri.has_username_and_password?).must_equal false
170
- _(@impuri.has_user_info?).must_equal false
158
+ _(impuri.has_userinfo?).must_equal false
159
+ _(impuri.has_credentials?).must_equal false
160
+ _(impuri.has_username_and_password?).must_equal false
161
+ _(impuri.has_user_info?).must_equal false
171
162
  end
172
163
 
173
164
  it 'must return true for has_scheme?()' do
174
- _(@impuri.has_scheme?).must_equal true
175
- _(@impuri.has_protocol?).must_equal true
176
- _(@impuri.has_scheme_name?).must_equal true
177
- _(@impuri.scheme?).must_equal true
178
- _(@impuri.protocol?).must_equal true
179
- _(@impuri.scheme_name?).must_equal true
165
+ _(impuri.has_scheme?).must_equal true
166
+ _(impuri.has_protocol?).must_equal true
167
+ _(impuri.has_scheme_name?).must_equal true
168
+ _(impuri.scheme?).must_equal true
169
+ _(impuri.protocol?).must_equal true
170
+ _(impuri.scheme_name?).must_equal true
180
171
  end
181
172
 
182
173
  it 'must return false for has_colon_path_separator?()' do
183
- _(@impuri.has_colon_path_separator?).must_equal false
184
- _(@impuri.uses_colon_path_separator?).must_equal false
174
+ _(impuri.has_colon_path_separator?).must_equal false
175
+ _(impuri.uses_colon_path_separator?).must_equal false
185
176
  end
186
177
 
187
178
  it 'must return false for has_port_number?()' do
188
- _(@impuri.has_port_number?).must_equal false
189
- _(@impuri.has_port?).must_equal false
190
- _(@impuri.has_portnumber?).must_equal false
191
- _(@impuri.port_number?).must_equal false
192
- _(@impuri.port?).must_equal false
193
- _(@impuri.portnumber?).must_equal false
179
+ _(impuri.has_port_number?).must_equal false
180
+ _(impuri.has_port?).must_equal false
181
+ _(impuri.has_portnumber?).must_equal false
182
+ _(impuri.port_number?).must_equal false
183
+ _(impuri.port?).must_equal false
184
+ _(impuri.portnumber?).must_equal false
194
185
  end
195
186
 
196
187
  it 'must return the request URI' do
197
- _(@impuri.request_uri).must_equal '/path/to/resource'
188
+ _(impuri.request_uri).must_equal '/path/to/resource'
198
189
  end
199
190
  end # describe 'an http URI with a path'
200
191
 
201
192
  describe 'an http URI with a username' do
202
- before do
203
- @impuri = ImpURI.new('http://user@example.com/')
204
- end
193
+ let(:impuri){ImpURI.new('http://user@example.com/')}
205
194
 
206
195
  it 'must parse out the scheme' do
207
- _(@impuri.scheme).must_equal 'http'
208
- _(@impuri.protocol).must_equal 'http'
209
- _(@impuri.scheme_name).must_equal 'http'
196
+ _(impuri.scheme).must_equal 'http'
197
+ _(impuri.protocol).must_equal 'http'
198
+ _(impuri.scheme_name).must_equal 'http'
210
199
  end
211
200
 
212
201
  it 'must parse out the domain name' do
213
- _(@impuri.hostname).must_equal 'example.com'
214
- _(@impuri.host).must_equal 'example.com'
202
+ _(impuri.hostname).must_equal 'example.com'
203
+ _(impuri.host).must_equal 'example.com'
215
204
  end
216
205
 
217
206
  it 'must parse out the username' do
218
- _(@impuri.username).must_equal 'user'
207
+ _(impuri.username).must_equal 'user'
219
208
  end
220
209
 
221
210
  it 'must return the userinfo string' do
222
- _(@impuri.userinfo).must_equal 'user'
223
- _(@impuri.credentials).must_equal 'user'
224
- _(@impuri.username_and_password).must_equal 'user'
225
- _(@impuri.user_info).must_equal 'user'
211
+ _(impuri.userinfo).must_equal 'user'
212
+ _(impuri.credentials).must_equal 'user'
213
+ _(impuri.username_and_password).must_equal 'user'
214
+ _(impuri.user_info).must_equal 'user'
226
215
  end
227
216
 
228
217
  it 'must return nil if there are no GET request parameters' do
229
- _(@impuri.parameter_string).must_be_nil
230
- _(@impuri.parameters).must_be_nil
218
+ _(impuri.parameter_string).must_be_nil
219
+ _(impuri.parameters).must_be_nil
231
220
  end
232
221
 
233
222
  it 'must return true for has_userinfo?()' do
234
- _(@impuri.has_userinfo?).must_equal true
235
- _(@impuri.has_credentials?).must_equal true
236
- _(@impuri.has_username_and_password?).must_equal true
237
- _(@impuri.has_user_info?).must_equal true
223
+ _(impuri.has_userinfo?).must_equal true
224
+ _(impuri.has_credentials?).must_equal true
225
+ _(impuri.has_username_and_password?).must_equal true
226
+ _(impuri.has_user_info?).must_equal true
238
227
  end
239
228
 
240
229
  it 'must return true for has_scheme?()' do
241
- _(@impuri.has_scheme?).must_equal true
242
- _(@impuri.has_protocol?).must_equal true
243
- _(@impuri.has_scheme_name?).must_equal true
244
- _(@impuri.scheme?).must_equal true
245
- _(@impuri.protocol?).must_equal true
246
- _(@impuri.scheme_name?).must_equal true
230
+ _(impuri.has_scheme?).must_equal true
231
+ _(impuri.has_protocol?).must_equal true
232
+ _(impuri.has_scheme_name?).must_equal true
233
+ _(impuri.scheme?).must_equal true
234
+ _(impuri.protocol?).must_equal true
235
+ _(impuri.scheme_name?).must_equal true
247
236
  end
248
237
 
249
238
  it 'must return false for has_colon_path_separator?()' do
250
- _(@impuri.has_colon_path_separator?).must_equal false
251
- _(@impuri.uses_colon_path_separator?).must_equal false
239
+ _(impuri.has_colon_path_separator?).must_equal false
240
+ _(impuri.uses_colon_path_separator?).must_equal false
252
241
  end
253
242
 
254
243
  it 'must return false for has_port_number?()' do
255
- _(@impuri.has_port_number?).must_equal false
256
- _(@impuri.has_port?).must_equal false
257
- _(@impuri.has_portnumber?).must_equal false
258
- _(@impuri.port_number?).must_equal false
259
- _(@impuri.port?).must_equal false
260
- _(@impuri.portnumber?).must_equal false
244
+ _(impuri.has_port_number?).must_equal false
245
+ _(impuri.has_port?).must_equal false
246
+ _(impuri.has_portnumber?).must_equal false
247
+ _(impuri.port_number?).must_equal false
248
+ _(impuri.port?).must_equal false
249
+ _(impuri.portnumber?).must_equal false
261
250
  end
262
251
 
263
252
  it 'must return nil if there is no request URI' do
264
- _(@impuri.request_uri).must_be_nil
253
+ _(impuri.request_uri).must_be_nil
265
254
  end
266
255
  end # describe 'an http URI with a username'
267
256
 
268
257
  describe 'an http URI with a username and password' do
269
- before do
270
- @impuri = ImpURI.new('http://user:pass@example.com/')
271
- end
258
+ let(:impuri){ImpURI.new('http://user:pass@example.com/')}
272
259
 
273
260
  it 'must parse out the scheme' do
274
- _(@impuri.scheme).must_equal 'http'
275
- _(@impuri.protocol).must_equal 'http'
276
- _(@impuri.scheme_name).must_equal 'http'
261
+ _(impuri.scheme).must_equal 'http'
262
+ _(impuri.protocol).must_equal 'http'
263
+ _(impuri.scheme_name).must_equal 'http'
277
264
  end
278
265
 
279
266
  it 'must parse out the domain name' do
280
- _(@impuri.hostname).must_equal 'example.com'
281
- _(@impuri.host).must_equal 'example.com'
267
+ _(impuri.hostname).must_equal 'example.com'
268
+ _(impuri.host).must_equal 'example.com'
282
269
  end
283
270
 
284
271
  it 'must parse out the username' do
285
- _(@impuri.username).must_equal 'user'
286
- _(@impuri.user).must_equal 'user'
272
+ _(impuri.username).must_equal 'user'
273
+ _(impuri.user).must_equal 'user'
287
274
  end
288
275
 
289
276
  it 'must parse out the password' do
290
- _(@impuri.password).must_equal 'pass'
291
- _(@impuri.pass).must_equal 'pass'
292
- _(@impuri.passwd).must_equal 'pass'
277
+ _(impuri.password).must_equal 'pass'
278
+ _(impuri.pass).must_equal 'pass'
279
+ _(impuri.passwd).must_equal 'pass'
293
280
  end
294
281
 
295
282
  it 'must return the userinfo string' do
296
- _(@impuri.userinfo).must_equal 'user:pass'
297
- _(@impuri.credentials).must_equal 'user:pass'
298
- _(@impuri.username_and_password).must_equal 'user:pass'
299
- _(@impuri.user_info).must_equal 'user:pass'
283
+ _(impuri.userinfo).must_equal 'user:pass'
284
+ _(impuri.credentials).must_equal 'user:pass'
285
+ _(impuri.username_and_password).must_equal 'user:pass'
286
+ _(impuri.user_info).must_equal 'user:pass'
300
287
  end
301
288
 
302
289
  it 'must return nil if there are no GET request parameters' do
303
- _(@impuri.parameter_string).must_be_nil
304
- _(@impuri.parameters).must_be_nil
290
+ _(impuri.parameter_string).must_be_nil
291
+ _(impuri.parameters).must_be_nil
305
292
  end
306
293
 
307
294
  it 'must return true for has_userinfo?()' do
308
- _(@impuri.has_userinfo?).must_equal true
309
- _(@impuri.has_credentials?).must_equal true
310
- _(@impuri.has_username_and_password?).must_equal true
311
- _(@impuri.has_user_info?).must_equal true
295
+ _(impuri.has_userinfo?).must_equal true
296
+ _(impuri.has_credentials?).must_equal true
297
+ _(impuri.has_username_and_password?).must_equal true
298
+ _(impuri.has_user_info?).must_equal true
312
299
  end
313
300
 
314
301
  it 'must return true for has_scheme?()' do
315
- _(@impuri.has_scheme?).must_equal true
316
- _(@impuri.has_protocol?).must_equal true
317
- _(@impuri.has_scheme_name?).must_equal true
318
- _(@impuri.scheme?).must_equal true
319
- _(@impuri.protocol?).must_equal true
320
- _(@impuri.scheme_name?).must_equal true
302
+ _(impuri.has_scheme?).must_equal true
303
+ _(impuri.has_protocol?).must_equal true
304
+ _(impuri.has_scheme_name?).must_equal true
305
+ _(impuri.scheme?).must_equal true
306
+ _(impuri.protocol?).must_equal true
307
+ _(impuri.scheme_name?).must_equal true
321
308
  end
322
309
 
323
310
  it 'must return false for has_colon_path_separator?()' do
324
- _(@impuri.has_colon_path_separator?).must_equal false
325
- _(@impuri.uses_colon_path_separator?).must_equal false
311
+ _(impuri.has_colon_path_separator?).must_equal false
312
+ _(impuri.uses_colon_path_separator?).must_equal false
326
313
  end
327
314
 
328
315
  it 'must return false for has_port_number?()' do
329
- _(@impuri.has_port_number?).must_equal false
330
- _(@impuri.has_port?).must_equal false
331
- _(@impuri.has_portnumber?).must_equal false
332
- _(@impuri.port_number?).must_equal false
333
- _(@impuri.port?).must_equal false
334
- _(@impuri.portnumber?).must_equal false
316
+ _(impuri.has_port_number?).must_equal false
317
+ _(impuri.has_port?).must_equal false
318
+ _(impuri.has_portnumber?).must_equal false
319
+ _(impuri.port_number?).must_equal false
320
+ _(impuri.port?).must_equal false
321
+ _(impuri.portnumber?).must_equal false
335
322
  end
336
323
 
337
324
  it 'must return nil if there is no request URI' do
338
- _(@impuri.request_uri).must_be_nil
325
+ _(impuri.request_uri).must_be_nil
339
326
  end
340
327
  end # describe 'an http URI with a username and password'
341
328
 
342
329
  describe 'an http URI with one GET query parameter' do
343
- before do
344
- @impuri = ImpURI.new('http://example.com/?q=param')
345
- end
330
+ let(:impuri){ImpURI.new('http://example.com/?q=param')}
346
331
 
347
332
  it 'must parse out the scheme' do
348
- _(@impuri.scheme).must_equal 'http'
349
- _(@impuri.protocol).must_equal 'http'
350
- _(@impuri.scheme_name).must_equal 'http'
333
+ _(impuri.scheme).must_equal 'http'
334
+ _(impuri.protocol).must_equal 'http'
335
+ _(impuri.scheme_name).must_equal 'http'
351
336
  end
352
337
 
353
338
  it 'must parse out the domain name' do
354
- _(@impuri.hostname).must_equal 'example.com'
355
- _(@impuri.host).must_equal 'example.com'
339
+ _(impuri.hostname).must_equal 'example.com'
340
+ _(impuri.host).must_equal 'example.com'
356
341
  end
357
342
 
358
343
  it 'must parse out the paramter string' do
359
- _(@impuri.parameter_string).must_equal 'q=param'
344
+ _(impuri.parameter_string).must_equal 'q=param'
360
345
  end
361
346
 
362
347
  it 'must parse out the parameter as a hash' do
363
- _(@impuri.parameters).must_equal({'q' => 'param'})
348
+ _(impuri.parameters).must_equal({'q' => 'param'})
364
349
  end
365
350
 
366
351
  it 'must return false for has_userinfo?()' do
367
- _(@impuri.has_userinfo?).must_equal false
368
- _(@impuri.has_credentials?).must_equal false
369
- _(@impuri.has_username_and_password?).must_equal false
370
- _(@impuri.has_user_info?).must_equal false
352
+ _(impuri.has_userinfo?).must_equal false
353
+ _(impuri.has_credentials?).must_equal false
354
+ _(impuri.has_username_and_password?).must_equal false
355
+ _(impuri.has_user_info?).must_equal false
371
356
  end
372
357
 
373
358
  it 'must return true for has_scheme?()' do
374
- _(@impuri.has_scheme?).must_equal true
375
- _(@impuri.has_protocol?).must_equal true
376
- _(@impuri.has_scheme_name?).must_equal true
377
- _(@impuri.scheme?).must_equal true
378
- _(@impuri.protocol?).must_equal true
379
- _(@impuri.scheme_name?).must_equal true
359
+ _(impuri.has_scheme?).must_equal true
360
+ _(impuri.has_protocol?).must_equal true
361
+ _(impuri.has_scheme_name?).must_equal true
362
+ _(impuri.scheme?).must_equal true
363
+ _(impuri.protocol?).must_equal true
364
+ _(impuri.scheme_name?).must_equal true
380
365
  end
381
366
 
382
367
  it 'must return false for has_colon_path_separator?()' do
383
- _(@impuri.has_colon_path_separator?).must_equal false
384
- _(@impuri.uses_colon_path_separator?).must_equal false
368
+ _(impuri.has_colon_path_separator?).must_equal false
369
+ _(impuri.uses_colon_path_separator?).must_equal false
385
370
  end
386
371
 
387
372
  it 'must return false for has_port_number?()' do
388
- _(@impuri.has_port_number?).must_equal false
389
- _(@impuri.has_port?).must_equal false
390
- _(@impuri.has_portnumber?).must_equal false
391
- _(@impuri.port_number?).must_equal false
392
- _(@impuri.port?).must_equal false
393
- _(@impuri.portnumber?).must_equal false
373
+ _(impuri.has_port_number?).must_equal false
374
+ _(impuri.has_port?).must_equal false
375
+ _(impuri.has_portnumber?).must_equal false
376
+ _(impuri.port_number?).must_equal false
377
+ _(impuri.port?).must_equal false
378
+ _(impuri.portnumber?).must_equal false
394
379
  end
395
380
 
396
381
  it 'must return the request URI' do
397
- _(@impuri.request_uri).must_equal '/?q=param'
382
+ _(impuri.request_uri).must_equal '/?q=param'
398
383
  end
399
384
  end # describe 'an http URI with one GET query parameter'
400
385
 
401
386
  describe 'an http URI with two GET query parameters' do
402
- before do
403
- @impuri = ImpURI.new('http://example.com/?q=param1&r=param2')
404
- end
387
+ let(:impuri){ImpURI.new('http://example.com/?q=param1&r=param2')}
405
388
 
406
389
  it 'must parse out the scheme' do
407
- _(@impuri.scheme).must_equal 'http'
408
- _(@impuri.protocol).must_equal 'http'
409
- _(@impuri.scheme_name).must_equal 'http'
390
+ _(impuri.scheme).must_equal 'http'
391
+ _(impuri.protocol).must_equal 'http'
392
+ _(impuri.scheme_name).must_equal 'http'
410
393
  end
411
394
 
412
395
  it 'must parse out the domain name' do
413
- _(@impuri.hostname).must_equal 'example.com'
414
- _(@impuri.host).must_equal 'example.com'
396
+ _(impuri.hostname).must_equal 'example.com'
397
+ _(impuri.host).must_equal 'example.com'
415
398
  end
416
399
 
417
400
  it 'must parse out the paramter string' do
418
- _(@impuri.parameter_string).must_equal 'q=param1&r=param2'
401
+ _(impuri.parameter_string).must_equal 'q=param1&r=param2'
419
402
  end
420
403
 
421
404
  it 'must parse out the parameter as a hash' do
422
- _(@impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
405
+ _(impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
423
406
  end
424
407
 
425
408
  it 'must return false for has_userinfo?()' do
426
- _(@impuri.has_userinfo?).must_equal false
427
- _(@impuri.has_credentials?).must_equal false
428
- _(@impuri.has_username_and_password?).must_equal false
429
- _(@impuri.has_user_info?).must_equal false
409
+ _(impuri.has_userinfo?).must_equal false
410
+ _(impuri.has_credentials?).must_equal false
411
+ _(impuri.has_username_and_password?).must_equal false
412
+ _(impuri.has_user_info?).must_equal false
430
413
  end
431
414
 
432
415
  it 'must return true for has_scheme?()' do
433
- _(@impuri.has_scheme?).must_equal true
434
- _(@impuri.has_protocol?).must_equal true
435
- _(@impuri.has_scheme_name?).must_equal true
436
- _(@impuri.scheme?).must_equal true
437
- _(@impuri.protocol?).must_equal true
438
- _(@impuri.scheme_name?).must_equal true
416
+ _(impuri.has_scheme?).must_equal true
417
+ _(impuri.has_protocol?).must_equal true
418
+ _(impuri.has_scheme_name?).must_equal true
419
+ _(impuri.scheme?).must_equal true
420
+ _(impuri.protocol?).must_equal true
421
+ _(impuri.scheme_name?).must_equal true
439
422
  end
440
423
 
441
424
  it 'must return false for has_colon_path_separator?()' do
442
- _(@impuri.has_colon_path_separator?).must_equal false
443
- _(@impuri.uses_colon_path_separator?).must_equal false
425
+ _(impuri.has_colon_path_separator?).must_equal false
426
+ _(impuri.uses_colon_path_separator?).must_equal false
444
427
  end
445
428
 
446
429
  it 'must return false for has_port_number?()' do
447
- _(@impuri.has_port_number?).must_equal false
448
- _(@impuri.has_port?).must_equal false
449
- _(@impuri.has_portnumber?).must_equal false
450
- _(@impuri.port_number?).must_equal false
451
- _(@impuri.port?).must_equal false
452
- _(@impuri.portnumber?).must_equal false
430
+ _(impuri.has_port_number?).must_equal false
431
+ _(impuri.has_port?).must_equal false
432
+ _(impuri.has_portnumber?).must_equal false
433
+ _(impuri.port_number?).must_equal false
434
+ _(impuri.port?).must_equal false
435
+ _(impuri.portnumber?).must_equal false
453
436
  end
454
437
 
455
438
  it 'must return the request URI' do
456
- _(@impuri.request_uri).must_equal '/?q=param1&r=param2'
439
+ _(impuri.request_uri).must_equal '/?q=param1&r=param2'
457
440
  end
458
441
  end # describe 'an http URI with two GET query parameters'
459
442
 
460
443
  describe 'an http URI with two GET query parameters separated by a semicolon' do
461
- before do
462
- @impuri = ImpURI.new('http://example.com/?q=param1;r=param2')
463
- end
444
+ let(:impuri){ImpURI.new('http://example.com/?q=param1;r=param2')}
464
445
 
465
446
  it 'must parse out the scheme' do
466
- _(@impuri.scheme).must_equal 'http'
467
- _(@impuri.protocol).must_equal 'http'
468
- _(@impuri.scheme_name).must_equal 'http'
447
+ _(impuri.scheme).must_equal 'http'
448
+ _(impuri.protocol).must_equal 'http'
449
+ _(impuri.scheme_name).must_equal 'http'
469
450
  end
470
451
 
471
452
  it 'must parse out the domain name' do
472
- _(@impuri.hostname).must_equal 'example.com'
473
- _(@impuri.host).must_equal 'example.com'
453
+ _(impuri.hostname).must_equal 'example.com'
454
+ _(impuri.host).must_equal 'example.com'
474
455
  end
475
456
 
476
457
  it 'must parse out the paramter string' do
477
- _(@impuri.parameter_string).must_equal 'q=param1;r=param2'
458
+ _(impuri.parameter_string).must_equal 'q=param1;r=param2'
478
459
  end
479
460
 
480
461
  it 'must parse out the parameter as a hash' do
481
- _(@impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
462
+ _(impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
482
463
  end
483
464
 
484
465
  it 'must return false for has_userinfo?()' do
485
- _(@impuri.has_userinfo?).must_equal false
486
- _(@impuri.has_credentials?).must_equal false
487
- _(@impuri.has_username_and_password?).must_equal false
488
- _(@impuri.has_user_info?).must_equal false
466
+ _(impuri.has_userinfo?).must_equal false
467
+ _(impuri.has_credentials?).must_equal false
468
+ _(impuri.has_username_and_password?).must_equal false
469
+ _(impuri.has_user_info?).must_equal false
489
470
  end
490
471
 
491
472
  it 'must return true for has_scheme?()' do
492
- _(@impuri.has_scheme?).must_equal true
493
- _(@impuri.has_protocol?).must_equal true
494
- _(@impuri.has_scheme_name?).must_equal true
495
- _(@impuri.scheme?).must_equal true
496
- _(@impuri.protocol?).must_equal true
497
- _(@impuri.scheme_name?).must_equal true
473
+ _(impuri.has_scheme?).must_equal true
474
+ _(impuri.has_protocol?).must_equal true
475
+ _(impuri.has_scheme_name?).must_equal true
476
+ _(impuri.scheme?).must_equal true
477
+ _(impuri.protocol?).must_equal true
478
+ _(impuri.scheme_name?).must_equal true
498
479
  end
499
480
 
500
481
  it 'must return false for has_colon_path_separator?()' do
501
- _(@impuri.has_colon_path_separator?).must_equal false
502
- _(@impuri.uses_colon_path_separator?).must_equal false
482
+ _(impuri.has_colon_path_separator?).must_equal false
483
+ _(impuri.uses_colon_path_separator?).must_equal false
503
484
  end
504
485
 
505
486
  it 'must return false for has_port_number?()' do
506
- _(@impuri.has_port_number?).must_equal false
507
- _(@impuri.has_port?).must_equal false
508
- _(@impuri.has_portnumber?).must_equal false
509
- _(@impuri.port_number?).must_equal false
510
- _(@impuri.port?).must_equal false
511
- _(@impuri.portnumber?).must_equal false
487
+ _(impuri.has_port_number?).must_equal false
488
+ _(impuri.has_port?).must_equal false
489
+ _(impuri.has_portnumber?).must_equal false
490
+ _(impuri.port_number?).must_equal false
491
+ _(impuri.port?).must_equal false
492
+ _(impuri.portnumber?).must_equal false
512
493
  end
513
494
 
514
495
  it 'must return the request URI' do
515
- _(@impuri.request_uri).must_equal '/?q=param1;r=param2'
496
+ _(impuri.request_uri).must_equal '/?q=param1;r=param2'
516
497
  end
517
498
  end # describe 'an http URI with two GET query parameters separated by a semicolon'
518
499
 
519
500
  describe 'an http URI with the lot' do
520
- before do
521
- @impuri = ImpURI.new('http://user:pass@example.com:8080/path/to/resource?q=param1&r=param2')
522
- end
501
+ let(:impuri){ImpURI.new('http://user:pass@example.com:8080/path/to/resource?q=param1&r=param2')}
523
502
 
524
503
  it 'must parse out the scheme' do
525
- _(@impuri.scheme).must_equal 'http'
526
- _(@impuri.protocol).must_equal 'http'
527
- _(@impuri.scheme_name).must_equal 'http'
504
+ _(impuri.scheme).must_equal 'http'
505
+ _(impuri.protocol).must_equal 'http'
506
+ _(impuri.scheme_name).must_equal 'http'
528
507
  end
529
508
 
530
509
  it 'must parse out the domain name' do
531
- _(@impuri.hostname).must_equal 'example.com'
532
- _(@impuri.host).must_equal 'example.com'
510
+ _(impuri.hostname).must_equal 'example.com'
511
+ _(impuri.host).must_equal 'example.com'
533
512
  end
534
513
 
535
514
  it 'must parse out the path' do
536
- _(@impuri.path).must_equal '/path/to/resource'
515
+ _(impuri.path).must_equal '/path/to/resource'
537
516
  end
538
517
 
539
518
  it 'must parse out the port number' do
540
- _(@impuri.port).must_equal '8080'
541
- _(@impuri.port_number).must_equal '8080'
542
- _(@impuri.port_number).must_equal '8080'
519
+ _(impuri.port).must_equal '8080'
520
+ _(impuri.port_number).must_equal '8080'
521
+ _(impuri.port_number).must_equal '8080'
543
522
  end
544
523
 
545
524
  it 'must parse out the username' do
546
- _(@impuri.username).must_equal 'user'
547
- _(@impuri.user).must_equal 'user'
525
+ _(impuri.username).must_equal 'user'
526
+ _(impuri.user).must_equal 'user'
548
527
  end
549
528
 
550
529
  it 'must parse out the password' do
551
- _(@impuri.password).must_equal 'pass'
552
- _(@impuri.pass).must_equal 'pass'
553
- _(@impuri.passwd).must_equal 'pass'
530
+ _(impuri.password).must_equal 'pass'
531
+ _(impuri.pass).must_equal 'pass'
532
+ _(impuri.passwd).must_equal 'pass'
554
533
  end
555
534
 
556
535
  it 'must return the userinfo string' do
557
- _(@impuri.userinfo).must_equal 'user:pass'
558
- _(@impuri.credentials).must_equal 'user:pass'
559
- _(@impuri.username_and_password).must_equal 'user:pass'
560
- _(@impuri.user_info).must_equal 'user:pass'
536
+ _(impuri.userinfo).must_equal 'user:pass'
537
+ _(impuri.credentials).must_equal 'user:pass'
538
+ _(impuri.username_and_password).must_equal 'user:pass'
539
+ _(impuri.user_info).must_equal 'user:pass'
561
540
  end
562
541
 
563
542
  it 'must parse out the paramter string' do
564
- _(@impuri.parameter_string).must_equal 'q=param1&r=param2'
543
+ _(impuri.parameter_string).must_equal 'q=param1&r=param2'
565
544
  end
566
545
 
567
546
  it 'must parse out the parameter as a hash' do
568
- _(@impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
547
+ _(impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
569
548
  end
570
549
 
571
550
  it 'must return true for has_userinfo?()' do
572
- _(@impuri.has_userinfo?).must_equal true
573
- _(@impuri.has_credentials?).must_equal true
574
- _(@impuri.has_username_and_password?).must_equal true
575
- _(@impuri.has_user_info?).must_equal true
551
+ _(impuri.has_userinfo?).must_equal true
552
+ _(impuri.has_credentials?).must_equal true
553
+ _(impuri.has_username_and_password?).must_equal true
554
+ _(impuri.has_user_info?).must_equal true
576
555
  end
577
556
 
578
557
  it 'must return true for has_scheme?()' do
579
- _(@impuri.has_scheme?).must_equal true
580
- _(@impuri.has_protocol?).must_equal true
581
- _(@impuri.has_scheme_name?).must_equal true
582
- _(@impuri.scheme?).must_equal true
583
- _(@impuri.protocol?).must_equal true
584
- _(@impuri.scheme_name?).must_equal true
558
+ _(impuri.has_scheme?).must_equal true
559
+ _(impuri.has_protocol?).must_equal true
560
+ _(impuri.has_scheme_name?).must_equal true
561
+ _(impuri.scheme?).must_equal true
562
+ _(impuri.protocol?).must_equal true
563
+ _(impuri.scheme_name?).must_equal true
585
564
  end
586
565
 
587
566
  it 'must return false for has_colon_path_separator?()' do
588
- _(@impuri.has_colon_path_separator?).must_equal false
589
- _(@impuri.uses_colon_path_separator?).must_equal false
567
+ _(impuri.has_colon_path_separator?).must_equal false
568
+ _(impuri.uses_colon_path_separator?).must_equal false
590
569
  end
591
570
 
592
571
  it 'must return true for has_port_number?()' do
593
- _(@impuri.has_port_number?).must_equal true
594
- _(@impuri.has_port?).must_equal true
595
- _(@impuri.has_portnumber?).must_equal true
596
- _(@impuri.port_number?).must_equal true
597
- _(@impuri.port?).must_equal true
598
- _(@impuri.portnumber?).must_equal true
572
+ _(impuri.has_port_number?).must_equal true
573
+ _(impuri.has_port?).must_equal true
574
+ _(impuri.has_portnumber?).must_equal true
575
+ _(impuri.port_number?).must_equal true
576
+ _(impuri.port?).must_equal true
577
+ _(impuri.portnumber?).must_equal true
599
578
  end
600
579
 
601
580
  it 'must return the request URI' do
602
- _(@impuri.request_uri).must_equal '/path/to/resource?q=param1&r=param2'
581
+ _(impuri.request_uri).must_equal '/path/to/resource?q=param1&r=param2'
603
582
  end
604
583
  end # describe 'an http URI with the lot'
605
584
 
606
585
  describe 'an http URI with the lot and a semicolon path separator' do
607
- before do
608
- @impuri = ImpURI.new('http://user:pass@example.com:8080/path/to/resource?q=param1;r=param2')
609
- end
586
+ let(:impuri){ImpURI.new('http://user:pass@example.com:8080/path/to/resource?q=param1;r=param2')}
610
587
 
611
588
  it 'must parse out the scheme' do
612
- _(@impuri.scheme).must_equal 'http'
613
- _(@impuri.protocol).must_equal 'http'
614
- _(@impuri.scheme_name).must_equal 'http'
589
+ _(impuri.scheme).must_equal 'http'
590
+ _(impuri.protocol).must_equal 'http'
591
+ _(impuri.scheme_name).must_equal 'http'
615
592
  end
616
593
 
617
594
  it 'must parse out the domain name' do
618
- _(@impuri.hostname).must_equal 'example.com'
619
- _(@impuri.host).must_equal 'example.com'
595
+ _(impuri.hostname).must_equal 'example.com'
596
+ _(impuri.host).must_equal 'example.com'
620
597
  end
621
598
 
622
599
  it 'must parse out the path' do
623
- _(@impuri.path).must_equal '/path/to/resource'
600
+ _(impuri.path).must_equal '/path/to/resource'
624
601
  end
625
602
 
626
603
  it 'must parse out the port number' do
627
- _(@impuri.port).must_equal '8080'
628
- _(@impuri.port_number).must_equal '8080'
629
- _(@impuri.port_number).must_equal '8080'
604
+ _(impuri.port).must_equal '8080'
605
+ _(impuri.port_number).must_equal '8080'
606
+ _(impuri.port_number).must_equal '8080'
630
607
  end
631
608
 
632
609
  it 'must parse out the username' do
633
- _(@impuri.username).must_equal 'user'
634
- _(@impuri.user).must_equal 'user'
610
+ _(impuri.username).must_equal 'user'
611
+ _(impuri.user).must_equal 'user'
635
612
  end
636
613
 
637
614
  it 'must parse out the password' do
638
- _(@impuri.password).must_equal 'pass'
639
- _(@impuri.pass).must_equal 'pass'
640
- _(@impuri.passwd).must_equal 'pass'
615
+ _(impuri.password).must_equal 'pass'
616
+ _(impuri.pass).must_equal 'pass'
617
+ _(impuri.passwd).must_equal 'pass'
641
618
  end
642
619
 
643
620
  it 'must return the userinfo string' do
644
- _(@impuri.userinfo).must_equal 'user:pass'
645
- _(@impuri.credentials).must_equal 'user:pass'
646
- _(@impuri.username_and_password).must_equal 'user:pass'
647
- _(@impuri.user_info).must_equal 'user:pass'
621
+ _(impuri.userinfo).must_equal 'user:pass'
622
+ _(impuri.credentials).must_equal 'user:pass'
623
+ _(impuri.username_and_password).must_equal 'user:pass'
624
+ _(impuri.user_info).must_equal 'user:pass'
648
625
  end
649
626
 
650
627
  it 'must parse out the paramter string' do
651
- _(@impuri.parameter_string).must_equal 'q=param1;r=param2'
628
+ _(impuri.parameter_string).must_equal 'q=param1;r=param2'
652
629
  end
653
630
 
654
631
  it 'must parse out the parameter as a hash' do
655
- _(@impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
632
+ _(impuri.parameters).must_equal({'q' => 'param1', 'r' => 'param2'})
656
633
  end
657
634
 
658
635
  it 'must return true for has_userinfo?()' do
659
- _(@impuri.has_userinfo?).must_equal true
660
- _(@impuri.has_credentials?).must_equal true
661
- _(@impuri.has_username_and_password?).must_equal true
662
- _(@impuri.has_user_info?).must_equal true
636
+ _(impuri.has_userinfo?).must_equal true
637
+ _(impuri.has_credentials?).must_equal true
638
+ _(impuri.has_username_and_password?).must_equal true
639
+ _(impuri.has_user_info?).must_equal true
663
640
  end
664
641
 
665
642
  it 'must return true for has_scheme?()' do
666
- _(@impuri.has_scheme?).must_equal true
667
- _(@impuri.has_protocol?).must_equal true
668
- _(@impuri.has_scheme_name?).must_equal true
669
- _(@impuri.scheme?).must_equal true
670
- _(@impuri.protocol?).must_equal true
671
- _(@impuri.scheme_name?).must_equal true
643
+ _(impuri.has_scheme?).must_equal true
644
+ _(impuri.has_protocol?).must_equal true
645
+ _(impuri.has_scheme_name?).must_equal true
646
+ _(impuri.scheme?).must_equal true
647
+ _(impuri.protocol?).must_equal true
648
+ _(impuri.scheme_name?).must_equal true
672
649
  end
673
650
 
674
651
  it 'must return false for has_colon_path_separator?()' do
675
- _(@impuri.has_colon_path_separator?).must_equal false
676
- _(@impuri.uses_colon_path_separator?).must_equal false
652
+ _(impuri.has_colon_path_separator?).must_equal false
653
+ _(impuri.uses_colon_path_separator?).must_equal false
677
654
  end
678
655
 
679
656
  it 'must return true for has_port_number?()' do
680
- _(@impuri.has_port_number?).must_equal true
681
- _(@impuri.has_port?).must_equal true
682
- _(@impuri.has_portnumber?).must_equal true
683
- _(@impuri.port_number?).must_equal true
684
- _(@impuri.port?).must_equal true
685
- _(@impuri.portnumber?).must_equal true
657
+ _(impuri.has_port_number?).must_equal true
658
+ _(impuri.has_port?).must_equal true
659
+ _(impuri.has_portnumber?).must_equal true
660
+ _(impuri.port_number?).must_equal true
661
+ _(impuri.port?).must_equal true
662
+ _(impuri.portnumber?).must_equal true
686
663
  end
687
664
 
688
665
  it 'must return the request URI' do
689
- _(@impuri.request_uri).must_equal '/path/to/resource?q=param1;r=param2'
666
+ _(impuri.request_uri).must_equal '/path/to/resource?q=param1;r=param2'
690
667
  end
691
668
  end # describe 'an http URI with the lot and a semicolon path separator'
692
669
 
693
670
  describe 'an ssh identifier' do
694
- before do
695
- @impuri = ImpURI.new('username@example.com:~account')
696
- end
671
+ let(:impuri){ImpURI.new('username@example.com:~account')}
697
672
 
698
673
  it 'must return a username' do
699
- _(@impuri.username).must_equal 'username'
674
+ _(impuri.username).must_equal 'username'
700
675
  end
701
676
 
702
677
  it 'must return true for is_ssh?()' do
703
- _(@impuri.is_ssh?).must_equal true
678
+ _(impuri.is_ssh?).must_equal true
704
679
  end
705
680
 
706
681
  it 'must correctly determine if it has user info' do
707
- _(@impuri.credentials?).must_equal false
708
- _(@impuri.username_and_password?).must_equal false
709
- _(@impuri.user_info?).must_equal false
710
- _(@impuri.userinfo?).must_equal false
711
- _(@impuri.has_credentials?).must_equal false
712
- _(@impuri.has_username_and_password?).must_equal false
713
- _(@impuri.has_user_info?).must_equal false
714
- _(@impuri.has_userinfo?).must_equal false
682
+ _(impuri.credentials?).must_equal false
683
+ _(impuri.username_and_password?).must_equal false
684
+ _(impuri.user_info?).must_equal false
685
+ _(impuri.userinfo?).must_equal false
686
+ _(impuri.has_credentials?).must_equal false
687
+ _(impuri.has_username_and_password?).must_equal false
688
+ _(impuri.has_user_info?).must_equal false
689
+ _(impuri.has_userinfo?).must_equal false
715
690
  end
716
691
 
717
692
  it 'must correctly determine if it has a colon path separator' do
718
- _(@impuri.colon_path_separator?).must_equal true
719
- _(@impuri.has_colon_path_separator?).must_equal true
720
- _(@impuri.uses_colon_path_separator?).must_equal true
693
+ _(impuri.colon_path_separator?).must_equal true
694
+ _(impuri.has_colon_path_separator?).must_equal true
695
+ _(impuri.uses_colon_path_separator?).must_equal true
721
696
  end
722
697
 
723
698
  it 'must correctly determine if it has a scheme' do
724
- _(@impuri.protocol?).must_equal false
725
- _(@impuri.scheme_name?).must_equal false
726
- _(@impuri.scheme?).must_equal false
727
- _(@impuri.has_protocol?).must_equal false
728
- _(@impuri.has_scheme_name?).must_equal false
729
- _(@impuri.has_scheme?).must_equal false
699
+ _(impuri.protocol?).must_equal false
700
+ _(impuri.scheme_name?).must_equal false
701
+ _(impuri.scheme?).must_equal false
702
+ _(impuri.has_protocol?).must_equal false
703
+ _(impuri.has_scheme_name?).must_equal false
704
+ _(impuri.has_scheme?).must_equal false
730
705
  end
731
706
 
732
707
  it 'must correctly determine if it has a port number' do
733
- _(@impuri.has_port_number?).must_equal false
734
- _(@impuri.has_port?).must_equal false
735
- _(@impuri.has_portnumber?).must_equal false
736
- _(@impuri.port_number?).must_equal false
737
- _(@impuri.port?).must_equal false
738
- _(@impuri.portnumber?).must_equal false
708
+ _(impuri.has_port_number?).must_equal false
709
+ _(impuri.has_port?).must_equal false
710
+ _(impuri.has_portnumber?).must_equal false
711
+ _(impuri.port_number?).must_equal false
712
+ _(impuri.port?).must_equal false
713
+ _(impuri.portnumber?).must_equal false
739
714
  end
740
715
 
741
716
  it 'must return hostname_and_path when requested' do
742
- _(@impuri.hostname_and_path).must_equal 'example.com:~account'
717
+ _(impuri.hostname_and_path).must_equal 'example.com:~account'
743
718
  end
744
719
 
745
720
  it 'must return hostname_and_port_number when requested' do
746
- _(@impuri.hostname_and_port_number).must_equal 'example.com'
721
+ _(impuri.hostname_and_port_number).must_equal 'example.com'
747
722
  end
748
723
 
749
724
  it 'must return a hostname' do
750
- _(@impuri.hostname).must_equal 'example.com'
725
+ _(impuri.hostname).must_equal 'example.com'
751
726
  end
752
727
 
753
728
  it 'must return a path' do
754
- _(@impuri.path).must_equal '~account'
729
+ _(impuri.path).must_equal '~account'
755
730
  end
756
731
  end # describe 'an ssh identifier'
757
732
 
758
733
  describe 'an ssh identifier as per Github' do
759
- before do
760
- @impuri = ImpURI.new('git@github.com:thoran/ImpURI.git')
761
- end
734
+ let(:impuri){ImpURI.new('git@github.com:thoran/ImpURI.git')}
762
735
 
763
736
  it 'must return a username' do
764
- _(@impuri.username).must_equal 'git'
737
+ _(impuri.username).must_equal 'git'
765
738
  end
766
739
 
767
740
  it 'must return true for is_ssh?()' do
768
- _(@impuri.is_ssh?).must_equal true
741
+ _(impuri.is_ssh?).must_equal true
769
742
  end
770
743
 
771
744
  it 'must correctly determine if it has user info' do
772
- _(@impuri.credentials?).must_equal false
773
- _(@impuri.username_and_password?).must_equal false
774
- _(@impuri.user_info?).must_equal false
775
- _(@impuri.userinfo?).must_equal false
776
- _(@impuri.has_credentials?).must_equal false
777
- _(@impuri.has_username_and_password?).must_equal false
778
- _(@impuri.has_user_info?).must_equal false
779
- _(@impuri.has_userinfo?).must_equal false
745
+ _(impuri.credentials?).must_equal false
746
+ _(impuri.username_and_password?).must_equal false
747
+ _(impuri.user_info?).must_equal false
748
+ _(impuri.userinfo?).must_equal false
749
+ _(impuri.has_credentials?).must_equal false
750
+ _(impuri.has_username_and_password?).must_equal false
751
+ _(impuri.has_user_info?).must_equal false
752
+ _(impuri.has_userinfo?).must_equal false
780
753
  end
781
754
 
782
755
  it 'must correctly determine if it has a colon path separator' do
783
- _(@impuri.colon_path_separator?).must_equal true
784
- _(@impuri.has_colon_path_separator?).must_equal true
785
- _(@impuri.uses_colon_path_separator?).must_equal true
756
+ _(impuri.colon_path_separator?).must_equal true
757
+ _(impuri.has_colon_path_separator?).must_equal true
758
+ _(impuri.uses_colon_path_separator?).must_equal true
786
759
  end
787
760
 
788
761
  it 'must correctly determine if it has a scheme' do
789
- _(@impuri.protocol?).must_equal false
790
- _(@impuri.scheme_name?).must_equal false
791
- _(@impuri.scheme?).must_equal false
792
- _(@impuri.has_protocol?).must_equal false
793
- _(@impuri.has_scheme_name?).must_equal false
794
- _(@impuri.has_scheme?).must_equal false
762
+ _(impuri.protocol?).must_equal false
763
+ _(impuri.scheme_name?).must_equal false
764
+ _(impuri.scheme?).must_equal false
765
+ _(impuri.has_protocol?).must_equal false
766
+ _(impuri.has_scheme_name?).must_equal false
767
+ _(impuri.has_scheme?).must_equal false
795
768
  end
796
769
 
797
770
  it 'must correctly determine if it has a port number' do
798
- _(@impuri.has_port_number?).must_equal false
799
- _(@impuri.has_port?).must_equal false
800
- _(@impuri.has_portnumber?).must_equal false
801
- _(@impuri.port_number?).must_equal false
802
- _(@impuri.port?).must_equal false
803
- _(@impuri.portnumber?).must_equal false
771
+ _(impuri.has_port_number?).must_equal false
772
+ _(impuri.has_port?).must_equal false
773
+ _(impuri.has_portnumber?).must_equal false
774
+ _(impuri.port_number?).must_equal false
775
+ _(impuri.port?).must_equal false
776
+ _(impuri.portnumber?).must_equal false
804
777
  end
805
778
 
806
779
  it 'must return hostname_and_path when requested' do
807
- _(@impuri.hostname_and_path).must_equal 'github.com:thoran/ImpURI.git'
780
+ _(impuri.hostname_and_path).must_equal 'github.com:thoran/ImpURI.git'
808
781
  end
809
782
 
810
783
  it 'must return hostname_and_port_number when requested' do
811
- _(@impuri.hostname_and_port_number).must_equal 'github.com'
784
+ _(impuri.hostname_and_port_number).must_equal 'github.com'
812
785
  end
813
786
 
814
787
  it 'must return a hostname' do
815
- _(@impuri.hostname).must_equal 'github.com'
788
+ _(impuri.hostname).must_equal 'github.com'
816
789
  end
817
790
 
818
791
  it 'must return a path' do
819
- _(@impuri.path).must_equal 'thoran/ImpURI.git'
792
+ _(impuri.path).must_equal 'thoran/ImpURI.git'
820
793
  end
821
794
  end # describe 'an ssh identifier as per Github'
822
-
823
795
  end # describe 'attribute readers'
824
796
 
825
797
  describe 'attribute writers' do
826
-
827
798
  describe 'a very simple http URI' do
828
- before do
829
- @impuri = ImpURI.new('http://example.com')
830
- end
799
+ let(:impuri){ImpURI.new('http://example.com')}
831
800
 
832
801
  it 'must assign the scheme' do
833
- @impuri.scheme = 'ftp'
834
- _(@impuri.scheme).must_equal 'ftp'
802
+ impuri.scheme = 'ftp'
803
+ _(impuri.scheme).must_equal 'ftp'
835
804
  end
836
805
 
837
806
  it 'must assign the username' do
838
- @impuri.username = 'user'
839
- _(@impuri.username).must_equal 'user'
807
+ impuri.username = 'user'
808
+ _(impuri.username).must_equal 'user'
840
809
  end
841
810
 
842
811
  it 'must assign the password' do
843
- @impuri.password = 'pass'
844
- _(@impuri.password).must_equal 'pass'
812
+ impuri.password = 'pass'
813
+ _(impuri.password).must_equal 'pass'
845
814
  end
846
815
 
847
816
  it 'must assign the hostname' do
848
- @impuri.hostname = 'example2.com'
849
- _(@impuri.hostname).must_equal 'example2.com'
817
+ impuri.hostname = 'example2.com'
818
+ _(impuri.hostname).must_equal 'example2.com'
850
819
  end
851
820
 
852
821
  it 'must assign the port number' do
853
- @impuri.port_number = '8080'
854
- _(@impuri.port_number).must_equal '8080'
822
+ impuri.port_number = '8080'
823
+ _(impuri.port_number).must_equal '8080'
855
824
  end
856
825
 
857
826
  it 'must assign the path' do
858
- @impuri.path = '/path/to/here'
859
- _(@impuri.path).must_equal '/path/to/here'
827
+ impuri.path = '/path/to/here'
828
+ _(impuri.path).must_equal '/path/to/here'
860
829
  end
861
830
 
862
831
  it 'must assign the parameter string' do
863
- @impuri.path = '/'
864
- @impuri.parameter_string = 'a=1&b=2'
865
- _(@impuri.parameter_string).must_equal 'a=1&b=2'
832
+ impuri.path = '/'
833
+ impuri.parameter_string = 'a=1&b=2'
834
+ _(impuri.parameter_string).must_equal 'a=1&b=2'
866
835
  end
867
836
 
868
837
  it 'must assign the parameter string and cause the parameters to be assigned also' do
869
- @impuri.path = '/'
870
- @impuri.parameter_string = 'a=1&b=2'
871
- _(@impuri.parameters).must_equal({'a' => '1', 'b' => '2'})
838
+ impuri.path = '/'
839
+ impuri.parameter_string = 'a=1&b=2'
840
+ _(impuri.parameters).must_equal({'a' => '1', 'b' => '2'})
872
841
  end
873
842
 
874
843
  it 'must assign the parameters and cause the parameter_sting to be assigned also' do
875
- @impuri.path = '/'
876
- @impuri.parameters = {'a' => '1', 'b' => '2'}
877
- _(@impuri.parameter_string).must_equal 'a=1&b=2'
844
+ impuri.path = '/'
845
+ impuri.parameters = {'a' => '1', 'b' => '2'}
846
+ _(impuri.parameter_string).must_equal 'a=1&b=2'
878
847
  end
879
848
 
880
849
  it 'must return true for has_userinfo?() after setting username and password' do
881
- @impuri.username = 'user'
882
- @impuri.password = 'pass'
883
- _(@impuri.has_userinfo?).must_equal true
850
+ impuri.username = 'user'
851
+ impuri.password = 'pass'
852
+ _(impuri.has_userinfo?).must_equal true
884
853
  end
885
854
 
886
855
  it 'must return true for has_port_number?() after setting the port number' do
887
- @impuri.port_number = '8080'
888
- _(@impuri.has_port_number?).must_equal true
856
+ impuri.port_number = '8080'
857
+ _(impuri.has_port_number?).must_equal true
889
858
  end
890
859
 
891
860
  it 'must return a URI string with all attributes which have been set' do
892
- @impuri.scheme = 'ftp'
893
- @impuri.username = 'user'
894
- @impuri.password = 'pass'
895
- @impuri.hostname = 'example2.com'
896
- @impuri.port_number = '8080'
897
- @impuri.path = '/path/to/here'
898
- @impuri.parameter_string = 'a=1&b=2'
899
- _(@impuri.to_s).must_equal 'ftp://user:pass@example2.com:8080/path/to/here?a=1&b=2'
861
+ impuri.scheme = 'ftp'
862
+ impuri.username = 'user'
863
+ impuri.password = 'pass'
864
+ impuri.hostname = 'example2.com'
865
+ impuri.port_number = '8080'
866
+ impuri.path = '/path/to/here'
867
+ impuri.parameter_string = 'a=1&b=2'
868
+ _(impuri.to_s).must_equal 'ftp://user:pass@example2.com:8080/path/to/here?a=1&b=2'
900
869
  end
901
870
  end # describe 'a very simple http URI'
902
-
903
871
  end # describe 'attribute writers'
904
872
 
873
+ describe '#to_ssh' do
874
+ describe 'a URI-style identifier' do
875
+ let(:impuri){ImpURI.new('github.com/thoran/lineage')}
876
+
877
+ # The slash stood between the hostname and the path rather than anchoring
878
+ # the path, and after a colon it would say the path began at the root.
879
+ it 'must not carry the separating slash into the path' do
880
+ _(impuri.to_ssh).must_equal 'github.com:thoran/lineage'
881
+ end
882
+ end # describe 'a URI-style identifier'
883
+
884
+ describe 'a URI-style identifier with a scheme' do
885
+ let(:impuri){ImpURI.new('https://github.com/thoran/lineage')}
886
+
887
+ it 'must leave the scheme out, there being no place for one' do
888
+ _(impuri.to_ssh).must_equal 'github.com:thoran/lineage'
889
+ end
890
+ end # describe 'a URI-style identifier with a scheme'
891
+
892
+ describe 'an ssh identifier with a path from the login directory' do
893
+ let(:impuri){ImpURI.new('git@github.com:thoran/lineage.git')}
894
+
895
+ it 'must return what it was given' do
896
+ _(impuri.to_ssh).must_equal 'git@github.com:thoran/lineage.git'
897
+ end
898
+ end # describe 'an ssh identifier with a path from the login directory'
899
+
900
+ describe 'an ssh identifier with a path from the root' do
901
+ let(:impuri){ImpURI.new('user@host.com:/srv/git/thing.git')}
902
+
903
+ it 'must keep the leading slash, that being the whole of the difference' do
904
+ _(impuri.to_ssh).must_equal 'user@host.com:/srv/git/thing.git'
905
+ end
906
+ end # describe 'an ssh identifier with a path from the root'
907
+
908
+ describe 'an identifier with a password' do
909
+ let(:impuri){ImpURI.new('user:pass@host.com:/srv/git/thing.git')}
910
+
911
+ it 'must render the username alone, ssh having no use for a password here' do
912
+ _(impuri.to_ssh).must_equal 'user@host.com:/srv/git/thing.git'
913
+ end
914
+ end # describe 'an identifier with a password'
915
+
916
+ describe 'an identifier with a port number' do
917
+ let(:impuri){ImpURI.new('http://example.com:8080/a/b')}
918
+
919
+ it 'must drop the port number, this form having nowhere to put one' do
920
+ _(impuri.to_ssh).must_equal 'example.com:a/b'
921
+ end
922
+ end # describe 'an identifier with a port number'
923
+
924
+ describe 'an identifier with no path' do
925
+ let(:impuri){ImpURI.new('example.com')}
926
+
927
+ it 'must return the hostname and a colon, being the login directory' do
928
+ _(impuri.to_ssh).must_equal 'example.com:'
929
+ end
930
+ end # describe 'an identifier with no path'
931
+ end # describe '#to_ssh'
932
+
933
+ describe '#username_with_separator' do
934
+ it 'must return the username and an at sign where there is one' do
935
+ _(ImpURI.new('git@github.com:thoran/lineage.git').username_with_separator).must_equal 'git@'
936
+ end
937
+
938
+ it 'must return an empty string where there is none' do
939
+ _(ImpURI.new('github.com/thoran/lineage').username_with_separator).must_equal ''
940
+ end
941
+ end # describe '#username_with_separator'
905
942
  end