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.
- checksums.yaml +4 -4
- data/CHANGELOG +27 -3
- data/README.md +22 -0
- data/{ImpURI.gemspec → impuri.gemspec} +1 -1
- data/lib/ImpURI/VERSION.rb +1 -1
- data/lib/{ImpURI.rb → impuri.rb} +15 -1
- data/test/ImpURI/class_methods.rb +437 -461
- data/test/ImpURI/instance_methods.rb +481 -444
- metadata +3 -3
|
@@ -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 '
|
|
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
|
-
_(
|
|
22
|
-
_(
|
|
23
|
-
_(
|
|
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
|
-
_(
|
|
28
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
37
|
-
_(
|
|
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
|
-
_(
|
|
42
|
-
_(
|
|
43
|
-
_(
|
|
44
|
-
_(
|
|
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
|
-
_(
|
|
49
|
-
_(
|
|
50
|
-
_(
|
|
51
|
-
_(
|
|
52
|
-
_(
|
|
53
|
-
_(
|
|
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
|
-
_(
|
|
58
|
-
_(
|
|
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
|
-
_(
|
|
63
|
-
_(
|
|
64
|
-
_(
|
|
65
|
-
_(
|
|
66
|
-
_(
|
|
67
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
82
|
-
_(
|
|
83
|
-
_(
|
|
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
|
-
_(
|
|
88
|
-
_(
|
|
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
|
-
_(
|
|
85
|
+
_(impuri.path).must_be_nil
|
|
93
86
|
end
|
|
94
87
|
|
|
95
88
|
it 'must parse out the port number' do
|
|
96
|
-
_(
|
|
97
|
-
_(
|
|
98
|
-
_(
|
|
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
|
-
_(
|
|
103
|
-
_(
|
|
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
|
-
_(
|
|
108
|
-
_(
|
|
109
|
-
_(
|
|
110
|
-
_(
|
|
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
|
-
_(
|
|
115
|
-
_(
|
|
116
|
-
_(
|
|
117
|
-
_(
|
|
118
|
-
_(
|
|
119
|
-
_(
|
|
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
|
-
_(
|
|
124
|
-
_(
|
|
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
|
-
_(
|
|
129
|
-
_(
|
|
130
|
-
_(
|
|
131
|
-
_(
|
|
132
|
-
_(
|
|
133
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
148
|
-
_(
|
|
149
|
-
_(
|
|
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
|
-
_(
|
|
154
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
163
|
-
_(
|
|
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
|
-
_(
|
|
168
|
-
_(
|
|
169
|
-
_(
|
|
170
|
-
_(
|
|
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
|
-
_(
|
|
175
|
-
_(
|
|
176
|
-
_(
|
|
177
|
-
_(
|
|
178
|
-
_(
|
|
179
|
-
_(
|
|
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
|
-
_(
|
|
184
|
-
_(
|
|
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
|
-
_(
|
|
189
|
-
_(
|
|
190
|
-
_(
|
|
191
|
-
_(
|
|
192
|
-
_(
|
|
193
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
208
|
-
_(
|
|
209
|
-
_(
|
|
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
|
-
_(
|
|
214
|
-
_(
|
|
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
|
-
_(
|
|
207
|
+
_(impuri.username).must_equal 'user'
|
|
219
208
|
end
|
|
220
209
|
|
|
221
210
|
it 'must return the userinfo string' do
|
|
222
|
-
_(
|
|
223
|
-
_(
|
|
224
|
-
_(
|
|
225
|
-
_(
|
|
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
|
-
_(
|
|
230
|
-
_(
|
|
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
|
-
_(
|
|
235
|
-
_(
|
|
236
|
-
_(
|
|
237
|
-
_(
|
|
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
|
-
_(
|
|
242
|
-
_(
|
|
243
|
-
_(
|
|
244
|
-
_(
|
|
245
|
-
_(
|
|
246
|
-
_(
|
|
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
|
-
_(
|
|
251
|
-
_(
|
|
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
|
-
_(
|
|
256
|
-
_(
|
|
257
|
-
_(
|
|
258
|
-
_(
|
|
259
|
-
_(
|
|
260
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
275
|
-
_(
|
|
276
|
-
_(
|
|
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
|
-
_(
|
|
281
|
-
_(
|
|
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
|
-
_(
|
|
286
|
-
_(
|
|
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
|
-
_(
|
|
291
|
-
_(
|
|
292
|
-
_(
|
|
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
|
-
_(
|
|
297
|
-
_(
|
|
298
|
-
_(
|
|
299
|
-
_(
|
|
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
|
-
_(
|
|
304
|
-
_(
|
|
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
|
-
_(
|
|
309
|
-
_(
|
|
310
|
-
_(
|
|
311
|
-
_(
|
|
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
|
-
_(
|
|
316
|
-
_(
|
|
317
|
-
_(
|
|
318
|
-
_(
|
|
319
|
-
_(
|
|
320
|
-
_(
|
|
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
|
-
_(
|
|
325
|
-
_(
|
|
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
|
-
_(
|
|
330
|
-
_(
|
|
331
|
-
_(
|
|
332
|
-
_(
|
|
333
|
-
_(
|
|
334
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
349
|
-
_(
|
|
350
|
-
_(
|
|
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
|
-
_(
|
|
355
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
348
|
+
_(impuri.parameters).must_equal({'q' => 'param'})
|
|
364
349
|
end
|
|
365
350
|
|
|
366
351
|
it 'must return false for has_userinfo?()' do
|
|
367
|
-
_(
|
|
368
|
-
_(
|
|
369
|
-
_(
|
|
370
|
-
_(
|
|
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
|
-
_(
|
|
375
|
-
_(
|
|
376
|
-
_(
|
|
377
|
-
_(
|
|
378
|
-
_(
|
|
379
|
-
_(
|
|
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
|
-
_(
|
|
384
|
-
_(
|
|
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
|
-
_(
|
|
389
|
-
_(
|
|
390
|
-
_(
|
|
391
|
-
_(
|
|
392
|
-
_(
|
|
393
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
408
|
-
_(
|
|
409
|
-
_(
|
|
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
|
-
_(
|
|
414
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
427
|
-
_(
|
|
428
|
-
_(
|
|
429
|
-
_(
|
|
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
|
-
_(
|
|
434
|
-
_(
|
|
435
|
-
_(
|
|
436
|
-
_(
|
|
437
|
-
_(
|
|
438
|
-
_(
|
|
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
|
-
_(
|
|
443
|
-
_(
|
|
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
|
-
_(
|
|
448
|
-
_(
|
|
449
|
-
_(
|
|
450
|
-
_(
|
|
451
|
-
_(
|
|
452
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
467
|
-
_(
|
|
468
|
-
_(
|
|
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
|
-
_(
|
|
473
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
486
|
-
_(
|
|
487
|
-
_(
|
|
488
|
-
_(
|
|
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
|
-
_(
|
|
493
|
-
_(
|
|
494
|
-
_(
|
|
495
|
-
_(
|
|
496
|
-
_(
|
|
497
|
-
_(
|
|
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
|
-
_(
|
|
502
|
-
_(
|
|
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
|
-
_(
|
|
507
|
-
_(
|
|
508
|
-
_(
|
|
509
|
-
_(
|
|
510
|
-
_(
|
|
511
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
526
|
-
_(
|
|
527
|
-
_(
|
|
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
|
-
_(
|
|
532
|
-
_(
|
|
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
|
-
_(
|
|
515
|
+
_(impuri.path).must_equal '/path/to/resource'
|
|
537
516
|
end
|
|
538
517
|
|
|
539
518
|
it 'must parse out the port number' do
|
|
540
|
-
_(
|
|
541
|
-
_(
|
|
542
|
-
_(
|
|
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
|
-
_(
|
|
547
|
-
_(
|
|
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
|
-
_(
|
|
552
|
-
_(
|
|
553
|
-
_(
|
|
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
|
-
_(
|
|
558
|
-
_(
|
|
559
|
-
_(
|
|
560
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
573
|
-
_(
|
|
574
|
-
_(
|
|
575
|
-
_(
|
|
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
|
-
_(
|
|
580
|
-
_(
|
|
581
|
-
_(
|
|
582
|
-
_(
|
|
583
|
-
_(
|
|
584
|
-
_(
|
|
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
|
-
_(
|
|
589
|
-
_(
|
|
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
|
-
_(
|
|
594
|
-
_(
|
|
595
|
-
_(
|
|
596
|
-
_(
|
|
597
|
-
_(
|
|
598
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
613
|
-
_(
|
|
614
|
-
_(
|
|
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
|
-
_(
|
|
619
|
-
_(
|
|
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
|
-
_(
|
|
600
|
+
_(impuri.path).must_equal '/path/to/resource'
|
|
624
601
|
end
|
|
625
602
|
|
|
626
603
|
it 'must parse out the port number' do
|
|
627
|
-
_(
|
|
628
|
-
_(
|
|
629
|
-
_(
|
|
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
|
-
_(
|
|
634
|
-
_(
|
|
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
|
-
_(
|
|
639
|
-
_(
|
|
640
|
-
_(
|
|
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
|
-
_(
|
|
645
|
-
_(
|
|
646
|
-
_(
|
|
647
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
660
|
-
_(
|
|
661
|
-
_(
|
|
662
|
-
_(
|
|
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
|
-
_(
|
|
667
|
-
_(
|
|
668
|
-
_(
|
|
669
|
-
_(
|
|
670
|
-
_(
|
|
671
|
-
_(
|
|
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
|
-
_(
|
|
676
|
-
_(
|
|
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
|
-
_(
|
|
681
|
-
_(
|
|
682
|
-
_(
|
|
683
|
-
_(
|
|
684
|
-
_(
|
|
685
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
674
|
+
_(impuri.username).must_equal 'username'
|
|
700
675
|
end
|
|
701
676
|
|
|
702
677
|
it 'must return true for is_ssh?()' do
|
|
703
|
-
_(
|
|
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
|
-
_(
|
|
708
|
-
_(
|
|
709
|
-
_(
|
|
710
|
-
_(
|
|
711
|
-
_(
|
|
712
|
-
_(
|
|
713
|
-
_(
|
|
714
|
-
_(
|
|
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
|
-
_(
|
|
719
|
-
_(
|
|
720
|
-
_(
|
|
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
|
-
_(
|
|
725
|
-
_(
|
|
726
|
-
_(
|
|
727
|
-
_(
|
|
728
|
-
_(
|
|
729
|
-
_(
|
|
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
|
-
_(
|
|
734
|
-
_(
|
|
735
|
-
_(
|
|
736
|
-
_(
|
|
737
|
-
_(
|
|
738
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
721
|
+
_(impuri.hostname_and_port_number).must_equal 'example.com'
|
|
747
722
|
end
|
|
748
723
|
|
|
749
724
|
it 'must return a hostname' do
|
|
750
|
-
_(
|
|
725
|
+
_(impuri.hostname).must_equal 'example.com'
|
|
751
726
|
end
|
|
752
727
|
|
|
753
728
|
it 'must return a path' do
|
|
754
|
-
_(
|
|
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
|
-
|
|
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
|
-
_(
|
|
737
|
+
_(impuri.username).must_equal 'git'
|
|
765
738
|
end
|
|
766
739
|
|
|
767
740
|
it 'must return true for is_ssh?()' do
|
|
768
|
-
_(
|
|
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
|
-
_(
|
|
773
|
-
_(
|
|
774
|
-
_(
|
|
775
|
-
_(
|
|
776
|
-
_(
|
|
777
|
-
_(
|
|
778
|
-
_(
|
|
779
|
-
_(
|
|
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
|
-
_(
|
|
784
|
-
_(
|
|
785
|
-
_(
|
|
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
|
-
_(
|
|
790
|
-
_(
|
|
791
|
-
_(
|
|
792
|
-
_(
|
|
793
|
-
_(
|
|
794
|
-
_(
|
|
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
|
-
_(
|
|
799
|
-
_(
|
|
800
|
-
_(
|
|
801
|
-
_(
|
|
802
|
-
_(
|
|
803
|
-
_(
|
|
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
|
-
_(
|
|
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
|
-
_(
|
|
784
|
+
_(impuri.hostname_and_port_number).must_equal 'github.com'
|
|
812
785
|
end
|
|
813
786
|
|
|
814
787
|
it 'must return a hostname' do
|
|
815
|
-
_(
|
|
788
|
+
_(impuri.hostname).must_equal 'github.com'
|
|
816
789
|
end
|
|
817
790
|
|
|
818
791
|
it 'must return a path' do
|
|
819
|
-
_(
|
|
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
|
-
|
|
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
|
-
|
|
834
|
-
_(
|
|
802
|
+
impuri.scheme = 'ftp'
|
|
803
|
+
_(impuri.scheme).must_equal 'ftp'
|
|
835
804
|
end
|
|
836
805
|
|
|
837
806
|
it 'must assign the username' do
|
|
838
|
-
|
|
839
|
-
_(
|
|
807
|
+
impuri.username = 'user'
|
|
808
|
+
_(impuri.username).must_equal 'user'
|
|
840
809
|
end
|
|
841
810
|
|
|
842
811
|
it 'must assign the password' do
|
|
843
|
-
|
|
844
|
-
_(
|
|
812
|
+
impuri.password = 'pass'
|
|
813
|
+
_(impuri.password).must_equal 'pass'
|
|
845
814
|
end
|
|
846
815
|
|
|
847
816
|
it 'must assign the hostname' do
|
|
848
|
-
|
|
849
|
-
_(
|
|
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
|
-
|
|
854
|
-
_(
|
|
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
|
-
|
|
859
|
-
_(
|
|
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
|
-
|
|
864
|
-
|
|
865
|
-
_(
|
|
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
|
-
|
|
870
|
-
|
|
871
|
-
_(
|
|
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
|
-
|
|
876
|
-
|
|
877
|
-
_(
|
|
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
|
-
|
|
882
|
-
|
|
883
|
-
_(
|
|
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
|
-
|
|
888
|
-
_(
|
|
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
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
_(
|
|
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
|