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