addressable 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +12 -1
- data/Gemfile +11 -15
- data/README.md +7 -7
- data/addressable.gemspec +37 -0
- data/lib/addressable/idna/pure.rb +34 -32
- data/lib/addressable/template.rb +25 -39
- data/lib/addressable/uri.rb +44 -17
- data/lib/addressable/version.rb +1 -1
- data/spec/addressable/idna_spec.rb +3 -1
- data/spec/addressable/template_spec.rb +9 -0
- data/spec/addressable/uri_spec.rb +265 -203
- data/spec/spec_helper.rb +9 -0
- data/tasks/gem.rake +0 -1
- data/tasks/profile.rake +72 -0
- data/tasks/rspec.rake +1 -1
- metadata +5 -5
- data/spec/addressable/rack_mount_compat_spec.rb +0 -106
data/lib/addressable/version.rb
CHANGED
@@ -294,7 +294,9 @@ begin
|
|
294
294
|
it_should_behave_like "converting from unicode to ASCII"
|
295
295
|
it_should_behave_like "converting from ASCII to unicode"
|
296
296
|
end
|
297
|
-
rescue LoadError
|
297
|
+
rescue LoadError => error
|
298
|
+
raise error if ENV["CI"] && TestHelper.native_supported?
|
299
|
+
|
298
300
|
# Cannot test the native implementation without libidn support.
|
299
301
|
warn('Could not load native IDN implementation.')
|
300
302
|
end
|
@@ -19,6 +19,7 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
require "bigdecimal"
|
22
|
+
require "timeout"
|
22
23
|
require "addressable/template"
|
23
24
|
|
24
25
|
shared_examples_for 'expands' do |tests|
|
@@ -1340,6 +1341,14 @@ describe Addressable::Template do
|
|
1340
1341
|
expect(subject).not_to match("foo_bar*")
|
1341
1342
|
expect(subject).not_to match("foo_bar:20")
|
1342
1343
|
end
|
1344
|
+
|
1345
|
+
it 'should parse in a reasonable time' do
|
1346
|
+
expect do
|
1347
|
+
Timeout.timeout(0.1) do
|
1348
|
+
expect(subject).not_to match("0"*25 + "!")
|
1349
|
+
end
|
1350
|
+
end.not_to raise_error
|
1351
|
+
end
|
1343
1352
|
end
|
1344
1353
|
context "VARIABLE_LIST" do
|
1345
1354
|
subject { Addressable::Template::VARIABLE_LIST }
|
@@ -65,116 +65,116 @@ end
|
|
65
65
|
|
66
66
|
describe Addressable::URI, "when created with a non-numeric port number" do
|
67
67
|
it "should raise an error" do
|
68
|
-
expect
|
68
|
+
expect do
|
69
69
|
Addressable::URI.new(:port => "bogus")
|
70
|
-
end
|
70
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe Addressable::URI, "when created with a invalid encoded port number" do
|
75
75
|
it "should raise an error" do
|
76
|
-
expect
|
76
|
+
expect do
|
77
77
|
Addressable::URI.new(:port => "%eb")
|
78
|
-
end
|
78
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
describe Addressable::URI, "when created with a non-string scheme" do
|
83
83
|
it "should raise an error" do
|
84
|
-
expect
|
84
|
+
expect do
|
85
85
|
Addressable::URI.new(:scheme => :bogus)
|
86
|
-
end
|
86
|
+
end.to raise_error(TypeError)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
describe Addressable::URI, "when created with a non-string user" do
|
91
91
|
it "should raise an error" do
|
92
|
-
expect
|
92
|
+
expect do
|
93
93
|
Addressable::URI.new(:user => :bogus)
|
94
|
-
end
|
94
|
+
end.to raise_error(TypeError)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
describe Addressable::URI, "when created with a non-string password" do
|
99
99
|
it "should raise an error" do
|
100
|
-
expect
|
100
|
+
expect do
|
101
101
|
Addressable::URI.new(:password => :bogus)
|
102
|
-
end
|
102
|
+
end.to raise_error(TypeError)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
describe Addressable::URI, "when created with a non-string userinfo" do
|
107
107
|
it "should raise an error" do
|
108
|
-
expect
|
108
|
+
expect do
|
109
109
|
Addressable::URI.new(:userinfo => :bogus)
|
110
|
-
end
|
110
|
+
end.to raise_error(TypeError)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
describe Addressable::URI, "when created with a non-string host" do
|
115
115
|
it "should raise an error" do
|
116
|
-
expect
|
116
|
+
expect do
|
117
117
|
Addressable::URI.new(:host => :bogus)
|
118
|
-
end
|
118
|
+
end.to raise_error(TypeError)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
describe Addressable::URI, "when created with a non-string authority" do
|
123
123
|
it "should raise an error" do
|
124
|
-
expect
|
124
|
+
expect do
|
125
125
|
Addressable::URI.new(:authority => :bogus)
|
126
|
-
end
|
126
|
+
end.to raise_error(TypeError)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
describe Addressable::URI, "when created with a non-string path" do
|
131
131
|
it "should raise an error" do
|
132
|
-
expect
|
132
|
+
expect do
|
133
133
|
Addressable::URI.new(:path => :bogus)
|
134
|
-
end
|
134
|
+
end.to raise_error(TypeError)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
138
|
describe Addressable::URI, "when created with a non-string query" do
|
139
139
|
it "should raise an error" do
|
140
|
-
expect
|
140
|
+
expect do
|
141
141
|
Addressable::URI.new(:query => :bogus)
|
142
|
-
end
|
142
|
+
end.to raise_error(TypeError)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
describe Addressable::URI, "when created with a non-string fragment" do
|
147
147
|
it "should raise an error" do
|
148
|
-
expect
|
148
|
+
expect do
|
149
149
|
Addressable::URI.new(:fragment => :bogus)
|
150
|
-
end
|
150
|
+
end.to raise_error(TypeError)
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
154
|
describe Addressable::URI, "when created with a scheme but no hierarchical " +
|
155
155
|
"segment" do
|
156
156
|
it "should raise an error" do
|
157
|
-
expect
|
157
|
+
expect do
|
158
158
|
Addressable::URI.parse("http:")
|
159
|
-
end
|
159
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
163
|
describe Addressable::URI, "quote handling" do
|
164
164
|
describe 'in host name' do
|
165
165
|
it "should raise an error for single quote" do
|
166
|
-
expect
|
166
|
+
expect do
|
167
167
|
Addressable::URI.parse("http://local\"host/")
|
168
|
-
end
|
168
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
173
|
describe Addressable::URI, "newline normalization" do
|
174
174
|
it "should not accept newlines in scheme" do
|
175
|
-
expect
|
175
|
+
expect do
|
176
176
|
Addressable::URI.parse("ht%0atp://localhost/")
|
177
|
-
end
|
177
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should not unescape newline in path" do
|
@@ -199,47 +199,47 @@ describe Addressable::URI, "newline normalization" do
|
|
199
199
|
|
200
200
|
it "should not accept newline in hostname" do
|
201
201
|
uri = Addressable::URI.parse("http://localhost/")
|
202
|
-
expect
|
202
|
+
expect do
|
203
203
|
uri.host = "local\nhost"
|
204
|
-
end
|
204
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
208
|
describe Addressable::URI, "when created with ambiguous path" do
|
209
209
|
it "should raise an error" do
|
210
|
-
expect
|
210
|
+
expect do
|
211
211
|
Addressable::URI.parse("::http")
|
212
|
-
end
|
212
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
216
|
describe Addressable::URI, "when created with an invalid host" do
|
217
217
|
it "should raise an error" do
|
218
|
-
expect
|
218
|
+
expect do
|
219
219
|
Addressable::URI.new(:host => "<invalid>")
|
220
|
-
end
|
220
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
224
|
describe Addressable::URI, "when created with a host consisting of " +
|
225
225
|
"sub-delims characters" do
|
226
226
|
it "should not raise an error" do
|
227
|
-
expect
|
227
|
+
expect do
|
228
228
|
Addressable::URI.new(
|
229
229
|
:host => Addressable::URI::CharacterClasses::SUB_DELIMS.gsub(/\\/, '')
|
230
230
|
)
|
231
|
-
end
|
231
|
+
end.not_to raise_error
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
235
|
describe Addressable::URI, "when created with a host consisting of " +
|
236
236
|
"unreserved characters" do
|
237
237
|
it "should not raise an error" do
|
238
|
-
expect
|
238
|
+
expect do
|
239
239
|
Addressable::URI.new(
|
240
240
|
:host => Addressable::URI::CharacterClasses::UNRESERVED.gsub(/\\/, '')
|
241
241
|
)
|
242
|
-
end
|
242
|
+
end.not_to raise_error
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -269,83 +269,83 @@ describe Addressable::URI, "when created from nil components" do
|
|
269
269
|
end
|
270
270
|
|
271
271
|
it "should raise an error if the scheme is set to whitespace" do
|
272
|
-
expect
|
272
|
+
expect do
|
273
273
|
@uri.scheme = "\t \n"
|
274
|
-
end
|
274
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'\t \n'/)
|
275
275
|
end
|
276
276
|
|
277
277
|
it "should raise an error if the scheme is set to all digits" do
|
278
|
-
expect
|
278
|
+
expect do
|
279
279
|
@uri.scheme = "123"
|
280
|
-
end
|
280
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'123'/)
|
281
281
|
end
|
282
282
|
|
283
283
|
it "should raise an error if the scheme begins with a digit" do
|
284
|
-
expect
|
284
|
+
expect do
|
285
285
|
@uri.scheme = "1scheme"
|
286
|
-
end
|
286
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'1scheme'/)
|
287
287
|
end
|
288
288
|
|
289
289
|
it "should raise an error if the scheme begins with a plus" do
|
290
|
-
expect
|
290
|
+
expect do
|
291
291
|
@uri.scheme = "+scheme"
|
292
|
-
end
|
292
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'\+scheme'/)
|
293
293
|
end
|
294
294
|
|
295
295
|
it "should raise an error if the scheme begins with a dot" do
|
296
|
-
expect
|
296
|
+
expect do
|
297
297
|
@uri.scheme = ".scheme"
|
298
|
-
end
|
298
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'\.scheme'/)
|
299
299
|
end
|
300
300
|
|
301
301
|
it "should raise an error if the scheme begins with a dash" do
|
302
|
-
expect
|
302
|
+
expect do
|
303
303
|
@uri.scheme = "-scheme"
|
304
|
-
end
|
304
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'-scheme'/)
|
305
305
|
end
|
306
306
|
|
307
307
|
it "should raise an error if the scheme contains an illegal character" do
|
308
|
-
expect
|
308
|
+
expect do
|
309
309
|
@uri.scheme = "scheme!"
|
310
|
-
end
|
310
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'scheme!'/)
|
311
311
|
end
|
312
312
|
|
313
313
|
it "should raise an error if the scheme contains whitespace" do
|
314
|
-
expect
|
314
|
+
expect do
|
315
315
|
@uri.scheme = "sch eme"
|
316
|
-
end
|
316
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /'sch eme'/)
|
317
317
|
end
|
318
318
|
|
319
319
|
it "should raise an error if the scheme contains a newline" do
|
320
|
-
expect
|
320
|
+
expect do
|
321
321
|
@uri.scheme = "sch\neme"
|
322
|
-
end
|
322
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
323
323
|
end
|
324
324
|
|
325
325
|
it "should raise an error if set into an invalid state" do
|
326
|
-
expect
|
326
|
+
expect do
|
327
327
|
@uri.user = "user"
|
328
|
-
end
|
328
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
329
329
|
end
|
330
330
|
|
331
331
|
it "should raise an error if set into an invalid state" do
|
332
|
-
expect
|
332
|
+
expect do
|
333
333
|
@uri.password = "pass"
|
334
|
-
end
|
334
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
335
335
|
end
|
336
336
|
|
337
337
|
it "should raise an error if set into an invalid state" do
|
338
|
-
expect
|
338
|
+
expect do
|
339
339
|
@uri.scheme = "http"
|
340
340
|
@uri.fragment = "fragment"
|
341
|
-
end
|
341
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
342
342
|
end
|
343
343
|
|
344
344
|
it "should raise an error if set into an invalid state" do
|
345
|
-
expect
|
345
|
+
expect do
|
346
346
|
@uri.fragment = "fragment"
|
347
347
|
@uri.scheme = "http"
|
348
|
-
end
|
348
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
349
349
|
end
|
350
350
|
end
|
351
351
|
|
@@ -1015,31 +1015,31 @@ describe Addressable::URI, "when created from string components" do
|
|
1015
1015
|
end
|
1016
1016
|
|
1017
1017
|
it "should raise an error if invalid components omitted" do
|
1018
|
-
expect
|
1018
|
+
expect do
|
1019
1019
|
@uri.omit(:bogus)
|
1020
|
-
end
|
1021
|
-
expect
|
1020
|
+
end.to raise_error(ArgumentError)
|
1021
|
+
expect do
|
1022
1022
|
@uri.omit(:scheme, :bogus, :path)
|
1023
|
-
end
|
1023
|
+
end.to raise_error(ArgumentError)
|
1024
1024
|
end
|
1025
1025
|
end
|
1026
1026
|
|
1027
1027
|
describe Addressable::URI, "when created with a nil host but " +
|
1028
1028
|
"non-nil authority components" do
|
1029
1029
|
it "should raise an error" do
|
1030
|
-
expect
|
1030
|
+
expect do
|
1031
1031
|
Addressable::URI.new(:user => "user", :password => "pass", :port => 80)
|
1032
|
-
end
|
1032
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1033
1033
|
end
|
1034
1034
|
end
|
1035
1035
|
|
1036
1036
|
describe Addressable::URI, "when created with both an authority and a user" do
|
1037
1037
|
it "should raise an error" do
|
1038
|
-
expect
|
1038
|
+
expect do
|
1039
1039
|
Addressable::URI.new(
|
1040
1040
|
:user => "user", :authority => "user@example.com:80"
|
1041
1041
|
)
|
1042
|
-
end
|
1042
|
+
end.to raise_error(ArgumentError)
|
1043
1043
|
end
|
1044
1044
|
end
|
1045
1045
|
|
@@ -1077,33 +1077,33 @@ end
|
|
1077
1077
|
|
1078
1078
|
describe Addressable::URI, "when created with a host with a backslash" do
|
1079
1079
|
it "should raise an error" do
|
1080
|
-
expect
|
1080
|
+
expect do
|
1081
1081
|
Addressable::URI.new(:authority => "example\\example")
|
1082
|
-
end
|
1082
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1083
1083
|
end
|
1084
1084
|
end
|
1085
1085
|
|
1086
1086
|
describe Addressable::URI, "when created with a host with a slash" do
|
1087
1087
|
it "should raise an error" do
|
1088
|
-
expect
|
1088
|
+
expect do
|
1089
1089
|
Addressable::URI.new(:authority => "example/example")
|
1090
|
-
end
|
1090
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1091
1091
|
end
|
1092
1092
|
end
|
1093
1093
|
|
1094
1094
|
describe Addressable::URI, "when created with a host with a space" do
|
1095
1095
|
it "should raise an error" do
|
1096
|
-
expect
|
1096
|
+
expect do
|
1097
1097
|
Addressable::URI.new(:authority => "example example")
|
1098
|
-
end
|
1098
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1099
1099
|
end
|
1100
1100
|
end
|
1101
1101
|
|
1102
1102
|
describe Addressable::URI, "when created with both a userinfo and a user" do
|
1103
1103
|
it "should raise an error" do
|
1104
|
-
expect
|
1104
|
+
expect do
|
1105
1105
|
Addressable::URI.new(:user => "user", :userinfo => "user:pass")
|
1106
|
-
end
|
1106
|
+
end.to raise_error(ArgumentError)
|
1107
1107
|
end
|
1108
1108
|
end
|
1109
1109
|
|
@@ -1195,18 +1195,18 @@ describe Addressable::URI, "when parsed from something that looks " +
|
|
1195
1195
|
"like a URI object" do
|
1196
1196
|
it "should parse without error" do
|
1197
1197
|
uri = Addressable::URI.parse(Fake::URI::HTTP.new("http://example.com/"))
|
1198
|
-
expect
|
1198
|
+
expect do
|
1199
1199
|
Addressable::URI.parse(uri)
|
1200
|
-
end
|
1200
|
+
end.not_to raise_error
|
1201
1201
|
end
|
1202
1202
|
end
|
1203
1203
|
|
1204
1204
|
describe Addressable::URI, "when parsed from a standard library URI object" do
|
1205
1205
|
it "should parse without error" do
|
1206
1206
|
uri = Addressable::URI.parse(URI.parse("http://example.com/"))
|
1207
|
-
expect
|
1207
|
+
expect do
|
1208
1208
|
Addressable::URI.parse(uri)
|
1209
|
-
end
|
1209
|
+
end.not_to raise_error
|
1210
1210
|
end
|
1211
1211
|
end
|
1212
1212
|
|
@@ -1366,9 +1366,9 @@ describe Addressable::URI, "when parsed from " +
|
|
1366
1366
|
end
|
1367
1367
|
|
1368
1368
|
it "should not allow request URI assignment" do
|
1369
|
-
expect
|
1369
|
+
expect do
|
1370
1370
|
@uri.request_uri = "/"
|
1371
|
-
end
|
1371
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1372
1372
|
end
|
1373
1373
|
|
1374
1374
|
it "should have a query of 'objectClass?one'" do
|
@@ -1390,9 +1390,9 @@ describe Addressable::URI, "when parsed from " +
|
|
1390
1390
|
end
|
1391
1391
|
|
1392
1392
|
it "should raise an error if omission would create an invalid URI" do
|
1393
|
-
expect
|
1393
|
+
expect do
|
1394
1394
|
@uri.omit(:authority, :path)
|
1395
|
-
end
|
1395
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1396
1396
|
end
|
1397
1397
|
|
1398
1398
|
it "should have an origin of 'ldap://[2001:db8::7]'" do
|
@@ -1778,9 +1778,9 @@ describe Addressable::URI, "when parsed from " +
|
|
1778
1778
|
|
1779
1779
|
it "should not be roughly equal to the string " +
|
1780
1780
|
"'http://example.com:bogus/'" do
|
1781
|
-
expect
|
1781
|
+
expect do
|
1782
1782
|
expect(@uri === "http://example.com:bogus/").to eq(false)
|
1783
|
-
end
|
1783
|
+
end.not_to raise_error
|
1784
1784
|
end
|
1785
1785
|
|
1786
1786
|
it "should result in itself when joined with itself" do
|
@@ -1810,21 +1810,21 @@ describe Addressable::URI, "when parsed from " +
|
|
1810
1810
|
end
|
1811
1811
|
|
1812
1812
|
it "should not allow origin assignment without scheme" do
|
1813
|
-
expect
|
1813
|
+
expect do
|
1814
1814
|
@uri.origin = "example.com"
|
1815
|
-
end
|
1815
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1816
1816
|
end
|
1817
1817
|
|
1818
1818
|
it "should not allow origin assignment without host" do
|
1819
|
-
expect
|
1819
|
+
expect do
|
1820
1820
|
@uri.origin = "http://"
|
1821
|
-
end
|
1821
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
1822
1822
|
end
|
1823
1823
|
|
1824
1824
|
it "should not allow origin assignment with bogus type" do
|
1825
|
-
expect
|
1825
|
+
expect do
|
1826
1826
|
@uri.origin = :bogus
|
1827
|
-
end
|
1827
|
+
end.to raise_error(TypeError)
|
1828
1828
|
end
|
1829
1829
|
|
1830
1830
|
# Section 6.2.3 of RFC 3986
|
@@ -1880,9 +1880,9 @@ describe Addressable::URI, "when parsed from " +
|
|
1880
1880
|
end
|
1881
1881
|
|
1882
1882
|
it "when joined with a bogus object a TypeError should be raised" do
|
1883
|
-
expect
|
1883
|
+
expect do
|
1884
1884
|
@uri.join(42)
|
1885
|
-
end
|
1885
|
+
end.to raise_error(TypeError)
|
1886
1886
|
end
|
1887
1887
|
|
1888
1888
|
it "should have the correct username after assignment" do
|
@@ -2015,15 +2015,15 @@ describe Addressable::URI, "when parsed from " +
|
|
2015
2015
|
end
|
2016
2016
|
|
2017
2017
|
it "should raise an error if the site value is set to something bogus" do
|
2018
|
-
expect
|
2018
|
+
expect do
|
2019
2019
|
@uri.site = 42
|
2020
|
-
end
|
2020
|
+
end.to raise_error(TypeError)
|
2021
2021
|
end
|
2022
2022
|
|
2023
2023
|
it "should raise an error if the request URI is set to something bogus" do
|
2024
|
-
expect
|
2024
|
+
expect do
|
2025
2025
|
@uri.request_uri = 42
|
2026
|
-
end
|
2026
|
+
end.to raise_error(TypeError)
|
2027
2027
|
end
|
2028
2028
|
|
2029
2029
|
it "should correctly convert to a hash" do
|
@@ -2072,9 +2072,9 @@ describe Addressable::URI, "when parsing IPv6 addresses" do
|
|
2072
2072
|
|
2073
2073
|
it "should raise an error for " +
|
2074
2074
|
"'http://[<invalid>]/'" do
|
2075
|
-
expect
|
2075
|
+
expect do
|
2076
2076
|
Addressable::URI.parse("http://[<invalid>]/")
|
2077
|
-
end
|
2077
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
2078
2078
|
end
|
2079
2079
|
end
|
2080
2080
|
|
@@ -2100,9 +2100,9 @@ describe Addressable::URI, "when assigning IPv6 address" do
|
|
2100
2100
|
it "should not allow to set bare IPv6 address as host" do
|
2101
2101
|
uri = Addressable::URI.parse("http://[::1]/")
|
2102
2102
|
skip "not checked"
|
2103
|
-
expect
|
2103
|
+
expect do
|
2104
2104
|
uri.host = '3ffe:1900:4545:3:200:f8ff:fe21:67cf'
|
2105
|
-
end
|
2105
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
2106
2106
|
end
|
2107
2107
|
end
|
2108
2108
|
|
@@ -2134,9 +2134,9 @@ describe Addressable::URI, "when parsing IPvFuture addresses" do
|
|
2134
2134
|
|
2135
2135
|
it "should raise an error for " +
|
2136
2136
|
"'http://[v0.<invalid>]/'" do
|
2137
|
-
expect
|
2137
|
+
expect do
|
2138
2138
|
Addressable::URI.parse("http://[v0.<invalid>]/")
|
2139
|
-
end
|
2139
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
2140
2140
|
end
|
2141
2141
|
end
|
2142
2142
|
|
@@ -2480,9 +2480,9 @@ describe Addressable::URI, "when parsed from " +
|
|
2480
2480
|
end
|
2481
2481
|
|
2482
2482
|
it "should not raise an exception when normalized" do
|
2483
|
-
expect
|
2483
|
+
expect do
|
2484
2484
|
@uri.normalize
|
2485
|
-
end
|
2485
|
+
end.not_to raise_error
|
2486
2486
|
end
|
2487
2487
|
|
2488
2488
|
it "should be considered to be in normal form" do
|
@@ -2534,9 +2534,9 @@ describe Addressable::URI, "when parsed from " +
|
|
2534
2534
|
end
|
2535
2535
|
|
2536
2536
|
it "should not raise an exception when normalized" do
|
2537
|
-
expect
|
2537
|
+
expect do
|
2538
2538
|
@uri.normalize
|
2539
|
-
end
|
2539
|
+
end.not_to raise_error
|
2540
2540
|
end
|
2541
2541
|
|
2542
2542
|
it "should be considered to be in normal form" do
|
@@ -2559,9 +2559,9 @@ describe Addressable::URI, "when parsed from " +
|
|
2559
2559
|
end
|
2560
2560
|
|
2561
2561
|
it "should not raise an exception when normalized" do
|
2562
|
-
expect
|
2562
|
+
expect do
|
2563
2563
|
@uri.normalize
|
2564
|
-
end
|
2564
|
+
end.not_to raise_error
|
2565
2565
|
end
|
2566
2566
|
|
2567
2567
|
it "should be considered to be in normal form" do
|
@@ -2597,9 +2597,9 @@ describe Addressable::URI, "when parsed from " +
|
|
2597
2597
|
end
|
2598
2598
|
|
2599
2599
|
it "should raise an error if encoding with an unexpected return type" do
|
2600
|
-
expect
|
2600
|
+
expect do
|
2601
2601
|
Addressable::URI.normalized_encode(@uri, Integer)
|
2602
|
-
end
|
2602
|
+
end.to raise_error(TypeError)
|
2603
2603
|
end
|
2604
2604
|
|
2605
2605
|
it "if percent encoded should be 'http://example.com/C%25CC%25A7'" do
|
@@ -2615,9 +2615,9 @@ describe Addressable::URI, "when parsed from " +
|
|
2615
2615
|
end
|
2616
2616
|
|
2617
2617
|
it "should raise an error if encoding with an unexpected return type" do
|
2618
|
-
expect
|
2618
|
+
expect do
|
2619
2619
|
Addressable::URI.encode(@uri, Integer)
|
2620
|
-
end
|
2620
|
+
end.to raise_error(TypeError)
|
2621
2621
|
end
|
2622
2622
|
|
2623
2623
|
it "should be identical to its duplicate" do
|
@@ -2752,9 +2752,9 @@ describe Addressable::URI, "when parsed from " +
|
|
2752
2752
|
|
2753
2753
|
it "should not be roughly equal to the string " +
|
2754
2754
|
"'http://example.com:bogus/'" do
|
2755
|
-
expect
|
2755
|
+
expect do
|
2756
2756
|
expect(@uri === "http://example.com:bogus/").to eq(false)
|
2757
|
-
end
|
2757
|
+
end.not_to raise_error
|
2758
2758
|
end
|
2759
2759
|
|
2760
2760
|
it "should result in itself when joined with itself" do
|
@@ -3100,9 +3100,9 @@ describe Addressable::URI, "when parsed from " +
|
|
3100
3100
|
end
|
3101
3101
|
|
3102
3102
|
it "should become invalid when normalized" do
|
3103
|
-
expect
|
3103
|
+
expect do
|
3104
3104
|
@uri.normalize
|
3105
|
-
end
|
3105
|
+
end.to raise_error(Addressable::URI::InvalidURIError, /authority/)
|
3106
3106
|
end
|
3107
3107
|
|
3108
3108
|
it "should have a path of '/..//example.com'" do
|
@@ -3340,12 +3340,12 @@ describe Addressable::URI, "when parsed from " +
|
|
3340
3340
|
end
|
3341
3341
|
|
3342
3342
|
it "should raise an error if routing is attempted" do
|
3343
|
-
expect
|
3343
|
+
expect do
|
3344
3344
|
@uri.route_to("http://example.com/")
|
3345
|
-
end
|
3346
|
-
expect
|
3345
|
+
end.to raise_error(ArgumentError, /relative\/path\/to\/resource/)
|
3346
|
+
expect do
|
3347
3347
|
@uri.route_from("http://example.com/")
|
3348
|
-
end
|
3348
|
+
end.to raise_error(ArgumentError, /relative\/path\/to\/resource/)
|
3349
3349
|
end
|
3350
3350
|
|
3351
3351
|
it "when joined with 'another/relative/path' should be " +
|
@@ -3942,9 +3942,9 @@ describe Addressable::URI, "when parsed from " +
|
|
3942
3942
|
end
|
3943
3943
|
|
3944
3944
|
it "should raise an error if assigning a bogus object to the hostname" do
|
3945
|
-
expect
|
3945
|
+
expect do
|
3946
3946
|
@uri.hostname = Object.new
|
3947
|
-
end
|
3947
|
+
end.to raise_error(TypeError)
|
3948
3948
|
end
|
3949
3949
|
|
3950
3950
|
it "should have the correct port after assignment" do
|
@@ -4023,9 +4023,9 @@ describe Addressable::URI, "when parsed from " +
|
|
4023
4023
|
end
|
4024
4024
|
|
4025
4025
|
it "should raise an error if query values are set to a bogus type" do
|
4026
|
-
expect
|
4026
|
+
expect do
|
4027
4027
|
@uri.query_values = "bogus"
|
4028
|
-
end
|
4028
|
+
end.to raise_error(TypeError)
|
4029
4029
|
end
|
4030
4030
|
|
4031
4031
|
it "should have the correct fragment after assignment" do
|
@@ -4097,39 +4097,39 @@ describe Addressable::URI, "when parsed from " +
|
|
4097
4097
|
end
|
4098
4098
|
|
4099
4099
|
it "should fail to merge with bogus values" do
|
4100
|
-
expect
|
4100
|
+
expect do
|
4101
4101
|
@uri.merge(:port => "bogus")
|
4102
|
-
end
|
4102
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
4103
4103
|
end
|
4104
4104
|
|
4105
4105
|
it "should fail to merge with bogus values" do
|
4106
|
-
expect
|
4106
|
+
expect do
|
4107
4107
|
@uri.merge(:authority => "bar@baz:bogus")
|
4108
|
-
end
|
4108
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
4109
4109
|
end
|
4110
4110
|
|
4111
4111
|
it "should fail to merge with bogus parameters" do
|
4112
|
-
expect
|
4112
|
+
expect do
|
4113
4113
|
@uri.merge(42)
|
4114
|
-
end
|
4114
|
+
end.to raise_error(TypeError)
|
4115
4115
|
end
|
4116
4116
|
|
4117
4117
|
it "should fail to merge with bogus parameters" do
|
4118
|
-
expect
|
4118
|
+
expect do
|
4119
4119
|
@uri.merge("http://example.com/")
|
4120
|
-
end
|
4120
|
+
end.to raise_error(TypeError)
|
4121
4121
|
end
|
4122
4122
|
|
4123
4123
|
it "should fail to merge with both authority and subcomponents" do
|
4124
|
-
expect
|
4124
|
+
expect do
|
4125
4125
|
@uri.merge(:authority => "foo:bar@baz:42", :port => "42")
|
4126
|
-
end
|
4126
|
+
end.to raise_error(ArgumentError)
|
4127
4127
|
end
|
4128
4128
|
|
4129
4129
|
it "should fail to merge with both userinfo and subcomponents" do
|
4130
|
-
expect
|
4130
|
+
expect do
|
4131
4131
|
@uri.merge(:userinfo => "foo:bar", :user => "foo")
|
4132
|
-
end
|
4132
|
+
end.to raise_error(ArgumentError)
|
4133
4133
|
end
|
4134
4134
|
|
4135
4135
|
it "should be identical to its duplicate" do
|
@@ -4262,6 +4262,36 @@ describe Addressable::URI, "when parsed from " +
|
|
4262
4262
|
end
|
4263
4263
|
end
|
4264
4264
|
|
4265
|
+
describe Addressable::URI, "when parsed from 'https://example.com/?q=a+b'" do
|
4266
|
+
before do
|
4267
|
+
@uri = Addressable::URI.parse("https://example.com/?q=a+b")
|
4268
|
+
end
|
4269
|
+
|
4270
|
+
it "should have query_values of {'q' => 'a b'}" do
|
4271
|
+
expect(@uri.query_values).to eq("q" => "a b")
|
4272
|
+
end
|
4273
|
+
end
|
4274
|
+
|
4275
|
+
describe Addressable::URI, "when parsed from 'example.com?q=a+b'" do
|
4276
|
+
before do
|
4277
|
+
@uri = Addressable::URI.parse("example.com?q=a+b")
|
4278
|
+
end
|
4279
|
+
|
4280
|
+
it "should have query_values of {'q' => 'a b'}" do
|
4281
|
+
expect(@uri.query_values).to eq("q" => "a b")
|
4282
|
+
end
|
4283
|
+
end
|
4284
|
+
|
4285
|
+
describe Addressable::URI, "when parsed from 'mailto:?q=a+b'" do
|
4286
|
+
before do
|
4287
|
+
@uri = Addressable::URI.parse("mailto:?q=a+b")
|
4288
|
+
end
|
4289
|
+
|
4290
|
+
it "should have query_values of {'q' => 'a+b'}" do
|
4291
|
+
expect(@uri.query_values).to eq("q" => "a+b")
|
4292
|
+
end
|
4293
|
+
end
|
4294
|
+
|
4265
4295
|
describe Addressable::URI, "when parsed from " +
|
4266
4296
|
"'http://example.com/?q=a%2bb'" do
|
4267
4297
|
before do
|
@@ -4323,6 +4353,26 @@ describe Addressable::URI, "when parsed from 'http://example/?&a&&c&'" do
|
|
4323
4353
|
end
|
4324
4354
|
end
|
4325
4355
|
|
4356
|
+
describe Addressable::URI, "when parsed from 'http://example.com/?a=1&a=1'" do
|
4357
|
+
before do
|
4358
|
+
@uri = Addressable::URI.parse("http://example.com/?a=1&a=1")
|
4359
|
+
end
|
4360
|
+
|
4361
|
+
it "should have a compacted normalized query of 'a=1'" do
|
4362
|
+
expect(@uri.normalized_query(:compacted)).to eq("a=1")
|
4363
|
+
end
|
4364
|
+
end
|
4365
|
+
|
4366
|
+
describe Addressable::URI, "when parsed from 'http://example.com/?a=1&a=2'" do
|
4367
|
+
before do
|
4368
|
+
@uri = Addressable::URI.parse("http://example.com/?a=1&a=2")
|
4369
|
+
end
|
4370
|
+
|
4371
|
+
it "should have a compacted normalized query of 'a=1&a=2'" do
|
4372
|
+
expect(@uri.normalized_query(:compacted)).to eq("a=1&a=2")
|
4373
|
+
end
|
4374
|
+
end
|
4375
|
+
|
4326
4376
|
describe Addressable::URI, "when parsed from " +
|
4327
4377
|
"'http://example.com/sound%2bvision'" do
|
4328
4378
|
before do
|
@@ -4434,10 +4484,10 @@ describe Addressable::URI, "when parsed from " +
|
|
4434
4484
|
end
|
4435
4485
|
|
4436
4486
|
it "should raise an error after nil assignment of authority segment" do
|
4437
|
-
expect
|
4487
|
+
expect do
|
4438
4488
|
# This would create an invalid URI
|
4439
4489
|
@uri.authority = nil
|
4440
|
-
end
|
4490
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
4441
4491
|
end
|
4442
4492
|
end
|
4443
4493
|
|
@@ -4666,12 +4716,12 @@ describe Addressable::URI, "when parsed from " +
|
|
4666
4716
|
end
|
4667
4717
|
|
4668
4718
|
it "should raise an error if routing is attempted" do
|
4669
|
-
expect
|
4719
|
+
expect do
|
4670
4720
|
@uri.route_to("http://example.com/")
|
4671
|
-
end
|
4672
|
-
expect
|
4721
|
+
end.to raise_error(ArgumentError, /\/\/example.com\//)
|
4722
|
+
expect do
|
4673
4723
|
@uri.route_from("http://example.com/")
|
4674
|
-
end
|
4724
|
+
end.to raise_error(ArgumentError, /\/\/example.com\//)
|
4675
4725
|
end
|
4676
4726
|
|
4677
4727
|
it "should have a 'null' origin" do
|
@@ -4765,9 +4815,9 @@ end
|
|
4765
4815
|
describe Addressable::URI, "when parsed from " +
|
4766
4816
|
"'http://under_score.example.com/'" do
|
4767
4817
|
it "should not cause an error" do
|
4768
|
-
expect
|
4818
|
+
expect do
|
4769
4819
|
Addressable::URI.parse("http://under_score.example.com/")
|
4770
|
-
end
|
4820
|
+
end.not_to raise_error
|
4771
4821
|
end
|
4772
4822
|
end
|
4773
4823
|
|
@@ -4839,9 +4889,9 @@ describe Addressable::URI, "when parsed from '?one=1&two=2&three=3'" do
|
|
4839
4889
|
end
|
4840
4890
|
|
4841
4891
|
it "should raise an error for invalid return type values" do
|
4842
|
-
expect
|
4892
|
+
expect do
|
4843
4893
|
@uri.query_values(Integer)
|
4844
|
-
end
|
4894
|
+
end.to raise_error(ArgumentError)
|
4845
4895
|
end
|
4846
4896
|
|
4847
4897
|
it "should have the correct array query values" do
|
@@ -5442,9 +5492,9 @@ describe Addressable::URI, "with a base uri of 'http://a/b/c/d;p?q'" do
|
|
5442
5492
|
end
|
5443
5493
|
|
5444
5494
|
it "when joined with a bogus object a TypeError should be raised" do
|
5445
|
-
expect
|
5495
|
+
expect do
|
5446
5496
|
Addressable::URI.join(@uri, 42)
|
5447
|
-
end
|
5497
|
+
end.to raise_error(TypeError)
|
5448
5498
|
end
|
5449
5499
|
end
|
5450
5500
|
|
@@ -5471,9 +5521,9 @@ end
|
|
5471
5521
|
|
5472
5522
|
describe Addressable::URI, "when converting a bogus path" do
|
5473
5523
|
it "should raise a TypeError" do
|
5474
|
-
expect
|
5524
|
+
expect do
|
5475
5525
|
Addressable::URI.convert_path(42)
|
5476
|
-
end
|
5526
|
+
end.to raise_error(TypeError)
|
5477
5527
|
end
|
5478
5528
|
end
|
5479
5529
|
|
@@ -5668,9 +5718,9 @@ describe Addressable::URI, "when parsing a non-String object" do
|
|
5668
5718
|
end
|
5669
5719
|
|
5670
5720
|
it "should raise a TypeError for objects than cannot be converted" do
|
5671
|
-
expect
|
5721
|
+
expect do
|
5672
5722
|
Addressable::URI.parse(42)
|
5673
|
-
end
|
5723
|
+
end.to raise_error(TypeError)
|
5674
5724
|
end
|
5675
5725
|
|
5676
5726
|
it "should correctly parse heuristically anything with a 'to_str' method" do
|
@@ -5678,9 +5728,9 @@ describe Addressable::URI, "when parsing a non-String object" do
|
|
5678
5728
|
end
|
5679
5729
|
|
5680
5730
|
it "should raise a TypeError for objects than cannot be converted" do
|
5681
|
-
expect
|
5731
|
+
expect do
|
5682
5732
|
Addressable::URI.heuristic_parse(42)
|
5683
|
-
end
|
5733
|
+
end.to raise_error(TypeError)
|
5684
5734
|
end
|
5685
5735
|
end
|
5686
5736
|
|
@@ -5724,9 +5774,9 @@ end
|
|
5724
5774
|
|
5725
5775
|
describe Addressable::URI, "when form encoding a non-Array object" do
|
5726
5776
|
it "should raise a TypeError for objects than cannot be converted" do
|
5727
|
-
expect
|
5777
|
+
expect do
|
5728
5778
|
Addressable::URI.form_encode(42)
|
5729
|
-
end
|
5779
|
+
end.to raise_error(TypeError)
|
5730
5780
|
end
|
5731
5781
|
end
|
5732
5782
|
|
@@ -5792,9 +5842,9 @@ describe Addressable::URI, "when form unencoding a non-String object" do
|
|
5792
5842
|
end
|
5793
5843
|
|
5794
5844
|
it "should raise a TypeError for objects than cannot be converted" do
|
5795
|
-
expect
|
5845
|
+
expect do
|
5796
5846
|
Addressable::URI.form_unencode(42)
|
5797
|
-
end
|
5847
|
+
end.to raise_error(TypeError)
|
5798
5848
|
end
|
5799
5849
|
end
|
5800
5850
|
|
@@ -5804,15 +5854,15 @@ describe Addressable::URI, "when normalizing a non-String object" do
|
|
5804
5854
|
end
|
5805
5855
|
|
5806
5856
|
it "should raise a TypeError for objects than cannot be converted" do
|
5807
|
-
expect
|
5857
|
+
expect do
|
5808
5858
|
Addressable::URI.normalize_component(42)
|
5809
|
-
end
|
5859
|
+
end.to raise_error(TypeError)
|
5810
5860
|
end
|
5811
5861
|
|
5812
5862
|
it "should raise a TypeError for objects than cannot be converted" do
|
5813
|
-
expect
|
5863
|
+
expect do
|
5814
5864
|
Addressable::URI.normalize_component("component", 42)
|
5815
|
-
end
|
5865
|
+
end.to raise_error(TypeError)
|
5816
5866
|
end
|
5817
5867
|
end
|
5818
5868
|
|
@@ -5884,6 +5934,18 @@ describe Addressable::URI, "when normalizing a string but leaving some character
|
|
5884
5934
|
end
|
5885
5935
|
end
|
5886
5936
|
|
5937
|
+
describe Addressable::URI, "when encoding IP literals" do
|
5938
|
+
it "should work for IPv4" do
|
5939
|
+
input = "http://127.0.0.1/"
|
5940
|
+
expect(Addressable::URI.encode(input)).to eq(input)
|
5941
|
+
end
|
5942
|
+
|
5943
|
+
it "should work for IPv6" do
|
5944
|
+
input = "http://[fe80::200:f8ff:fe21:67cf]/"
|
5945
|
+
expect(Addressable::URI.encode(input)).to eq(input)
|
5946
|
+
end
|
5947
|
+
end
|
5948
|
+
|
5887
5949
|
describe Addressable::URI, "when encoding a string with existing encodings to upcase" do
|
5888
5950
|
it "should result in correct percent encoded sequence" do
|
5889
5951
|
expect(Addressable::URI.encode_component("JK%4c", "0-9A-IKM-Za-z%", "L")).to eq("%4AK%4C")
|
@@ -5956,41 +6018,41 @@ end
|
|
5956
6018
|
|
5957
6019
|
describe Addressable::URI, "when unencoding a bogus object" do
|
5958
6020
|
it "should raise a TypeError" do
|
5959
|
-
expect
|
6021
|
+
expect do
|
5960
6022
|
Addressable::URI.unencode_component(42)
|
5961
|
-
end
|
6023
|
+
end.to raise_error(TypeError)
|
5962
6024
|
end
|
5963
6025
|
|
5964
6026
|
it "should raise a TypeError" do
|
5965
|
-
expect
|
6027
|
+
expect do
|
5966
6028
|
Addressable::URI.unencode("/path?g%C3%BCnther", Integer)
|
5967
|
-
end
|
6029
|
+
end.to raise_error(TypeError)
|
5968
6030
|
end
|
5969
6031
|
end
|
5970
6032
|
|
5971
6033
|
describe Addressable::URI, "when encoding a bogus object" do
|
5972
6034
|
it "should raise a TypeError" do
|
5973
|
-
expect
|
6035
|
+
expect do
|
5974
6036
|
Addressable::URI.encode(Object.new)
|
5975
|
-
end
|
6037
|
+
end.to raise_error(TypeError)
|
5976
6038
|
end
|
5977
6039
|
|
5978
6040
|
it "should raise a TypeError" do
|
5979
|
-
expect
|
6041
|
+
expect do
|
5980
6042
|
Addressable::URI.normalized_encode(Object.new)
|
5981
|
-
end
|
6043
|
+
end.to raise_error(TypeError)
|
5982
6044
|
end
|
5983
6045
|
|
5984
6046
|
it "should raise a TypeError" do
|
5985
|
-
expect
|
6047
|
+
expect do
|
5986
6048
|
Addressable::URI.encode_component("günther", Object.new)
|
5987
|
-
end
|
6049
|
+
end.to raise_error(TypeError)
|
5988
6050
|
end
|
5989
6051
|
|
5990
6052
|
it "should raise a TypeError" do
|
5991
|
-
expect
|
6053
|
+
expect do
|
5992
6054
|
Addressable::URI.encode_component(Object.new)
|
5993
|
-
end
|
6055
|
+
end.to raise_error(TypeError)
|
5994
6056
|
end
|
5995
6057
|
end
|
5996
6058
|
|
@@ -6006,9 +6068,9 @@ describe Addressable::URI, "when given the input " +
|
|
6006
6068
|
end
|
6007
6069
|
|
6008
6070
|
it "should not raise error when frozen" do
|
6009
|
-
expect
|
6071
|
+
expect do
|
6010
6072
|
Addressable::URI.heuristic_parse(@input).freeze.to_s
|
6011
|
-
end
|
6073
|
+
end.not_to raise_error
|
6012
6074
|
end
|
6013
6075
|
end
|
6014
6076
|
|
@@ -6421,54 +6483,54 @@ describe Addressable::URI, "when assigning query values" do
|
|
6421
6483
|
end
|
6422
6484
|
|
6423
6485
|
it "should raise an error attempting to assign {'a' => {'b' => ['c']}}" do
|
6424
|
-
expect
|
6486
|
+
expect do
|
6425
6487
|
@uri.query_values = { 'a' => {'b' => ['c'] } }
|
6426
|
-
end
|
6488
|
+
end.to raise_error(TypeError)
|
6427
6489
|
end
|
6428
6490
|
|
6429
6491
|
it "should raise an error attempting to assign " +
|
6430
6492
|
"{:b => '2', :a => {:c => '1'}}" do
|
6431
|
-
expect
|
6493
|
+
expect do
|
6432
6494
|
@uri.query_values = {:b => '2', :a => {:c => '1'}}
|
6433
|
-
end
|
6495
|
+
end.to raise_error(TypeError)
|
6434
6496
|
end
|
6435
6497
|
|
6436
6498
|
it "should raise an error attempting to assign " +
|
6437
6499
|
"{:a => 'a', :b => [{:c => 'c', :d => 'd'}, " +
|
6438
6500
|
"{:e => 'e', :f => 'f'}]}" do
|
6439
|
-
expect
|
6501
|
+
expect do
|
6440
6502
|
@uri.query_values = {
|
6441
6503
|
:a => "a", :b => [{:c => "c", :d => "d"}, {:e => "e", :f => "f"}]
|
6442
6504
|
}
|
6443
|
-
end
|
6505
|
+
end.to raise_error(TypeError)
|
6444
6506
|
end
|
6445
6507
|
|
6446
6508
|
it "should raise an error attempting to assign " +
|
6447
6509
|
"{:a => 'a', :b => [{:c => true, :d => 'd'}, " +
|
6448
6510
|
"{:e => 'e', :f => 'f'}]}" do
|
6449
|
-
expect
|
6511
|
+
expect do
|
6450
6512
|
@uri.query_values = {
|
6451
6513
|
:a => 'a', :b => [{:c => true, :d => 'd'}, {:e => 'e', :f => 'f'}]
|
6452
6514
|
}
|
6453
|
-
end
|
6515
|
+
end.to raise_error(TypeError)
|
6454
6516
|
end
|
6455
6517
|
|
6456
6518
|
it "should raise an error attempting to assign " +
|
6457
6519
|
"{:a => 'a', :b => {:c => true, :d => 'd'}}" do
|
6458
|
-
expect
|
6520
|
+
expect do
|
6459
6521
|
@uri.query_values = {
|
6460
6522
|
:a => 'a', :b => {:c => true, :d => 'd'}
|
6461
6523
|
}
|
6462
|
-
end
|
6524
|
+
end.to raise_error(TypeError)
|
6463
6525
|
end
|
6464
6526
|
|
6465
6527
|
it "should raise an error attempting to assign " +
|
6466
6528
|
"{:a => 'a', :b => {:c => true, :d => 'd'}}" do
|
6467
|
-
expect
|
6529
|
+
expect do
|
6468
6530
|
@uri.query_values = {
|
6469
6531
|
:a => 'a', :b => {:c => true, :d => 'd'}
|
6470
6532
|
}
|
6471
|
-
end
|
6533
|
+
end.to raise_error(TypeError)
|
6472
6534
|
end
|
6473
6535
|
|
6474
6536
|
it "should correctly assign {:a => 1, :b => 1.5}" do
|
@@ -6479,13 +6541,13 @@ describe Addressable::URI, "when assigning query values" do
|
|
6479
6541
|
it "should raise an error attempting to assign " +
|
6480
6542
|
"{:z => 1, :f => [2, {999.1 => [3,'4']}, ['h', 'i']], " +
|
6481
6543
|
":a => {:b => ['c', 'd'], :e => true, :y => 0.5}}" do
|
6482
|
-
expect
|
6544
|
+
expect do
|
6483
6545
|
@uri.query_values = {
|
6484
6546
|
:z => 1,
|
6485
6547
|
:f => [ 2, {999.1 => [3,'4']}, ['h', 'i'] ],
|
6486
6548
|
:a => { :b => ['c', 'd'], :e => true, :y => 0.5 }
|
6487
6549
|
}
|
6488
|
-
end
|
6550
|
+
end.to raise_error(TypeError)
|
6489
6551
|
end
|
6490
6552
|
|
6491
6553
|
it "should correctly assign {}" do
|
@@ -6535,7 +6597,7 @@ describe Addressable::URI, "when assigning path values" do
|
|
6535
6597
|
@uri.path = "acct:bob@sporkmonger.com"
|
6536
6598
|
expect(@uri.path).to eq("acct:bob@sporkmonger.com")
|
6537
6599
|
expect(@uri.normalize.to_str).to eq("acct%2Fbob@sporkmonger.com")
|
6538
|
-
expect
|
6600
|
+
expect { @uri.to_s }.to raise_error(
|
6539
6601
|
Addressable::URI::InvalidURIError
|
6540
6602
|
)
|
6541
6603
|
end
|
@@ -6553,26 +6615,26 @@ describe Addressable::URI, "when assigning path values" do
|
|
6553
6615
|
end
|
6554
6616
|
|
6555
6617
|
it "should not allow relative paths to be assigned on absolute URIs" do
|
6556
|
-
expect
|
6618
|
+
expect do
|
6557
6619
|
@uri.scheme = "http"
|
6558
6620
|
@uri.host = "example.com"
|
6559
6621
|
@uri.path = "acct:bob@sporkmonger.com"
|
6560
|
-
end
|
6622
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
6561
6623
|
end
|
6562
6624
|
|
6563
6625
|
it "should not allow relative paths to be assigned on absolute URIs" do
|
6564
|
-
expect
|
6626
|
+
expect do
|
6565
6627
|
@uri.path = "acct:bob@sporkmonger.com"
|
6566
6628
|
@uri.scheme = "http"
|
6567
6629
|
@uri.host = "example.com"
|
6568
|
-
end
|
6630
|
+
end.to raise_error(Addressable::URI::InvalidURIError)
|
6569
6631
|
end
|
6570
6632
|
|
6571
6633
|
it "should not allow relative paths to be assigned on absolute URIs" do
|
6572
|
-
expect
|
6634
|
+
expect do
|
6573
6635
|
@uri.path = "uuid:0b3ecf60-3f93-11df-a9c3-001f5bfffe12"
|
6574
6636
|
@uri.scheme = "urn"
|
6575
|
-
end
|
6637
|
+
end.not_to raise_error
|
6576
6638
|
end
|
6577
6639
|
end
|
6578
6640
|
|