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