iri 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_iri.rb CHANGED
@@ -1,28 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2019-2025 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
24
-
25
- require 'minitest/autorun'
3
+ # SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require_relative '../test/test__helper'
26
7
  require_relative '../lib/iri'
27
8
 
28
9
  # Iri test.
@@ -58,7 +39,11 @@ class IriTest < Minitest::Test
58
39
  'https://google.com/bar?x=900' => '/bar?x=900',
59
40
  'https://google.com/what#yes' => '/what#yes',
60
41
  'https://google.com/what?a=8&b=9#yes' => '/what?a=8&b=9#yes'
61
- }.each { |a, b| assert_equal(b, Iri.new(a).to_local) }
42
+ }.each { |a, b| assert_equal(b, Iri.new(a).to_local.to_s) }
43
+ end
44
+
45
+ def test_deals_with_local
46
+ assert_equal('/foo?x=1', Iri.new('https://google.com/foo').to_local.add(x: 1).to_s)
62
47
  end
63
48
 
64
49
  def test_broken_uri
@@ -199,4 +184,84 @@ class IriTest < Minitest::Test
199
184
  Iri.new('http://google/?a=1&b=2&c=3&a=33').over(a: 'hey').to_s
200
185
  )
201
186
  end
187
+
188
+ def test_rejects_nil_uri
189
+ assert_raises ArgumentError do
190
+ Iri.new(nil)
191
+ end
192
+ end
193
+
194
+ def test_rejects_nil_scheme
195
+ assert_raises ArgumentError do
196
+ Iri.new('http://google.com').scheme(nil)
197
+ end
198
+ end
199
+
200
+ def test_rejects_nil_host
201
+ assert_raises ArgumentError do
202
+ Iri.new('http://google.com').host(nil)
203
+ end
204
+ end
205
+
206
+ def test_rejects_nil_port
207
+ assert_raises ArgumentError do
208
+ Iri.new('http://google.com').port(nil)
209
+ end
210
+ end
211
+
212
+ def test_rejects_nil_path
213
+ assert_raises ArgumentError do
214
+ Iri.new('http://google.com').path(nil)
215
+ end
216
+ end
217
+
218
+ def test_rejects_nil_fragment
219
+ assert_raises ArgumentError do
220
+ Iri.new('http://google.com').fragment(nil)
221
+ end
222
+ end
223
+
224
+ def test_rejects_nil_query
225
+ assert_raises ArgumentError do
226
+ Iri.new('http://google.com').query(nil)
227
+ end
228
+ end
229
+
230
+ def test_rejects_nil_cut_path
231
+ assert_raises ArgumentError do
232
+ Iri.new('http://google.com/foo').cut(nil)
233
+ end
234
+ end
235
+
236
+ def test_rejects_nil_append_part
237
+ assert_raises ArgumentError do
238
+ Iri.new('http://google.com').append(nil)
239
+ end
240
+ end
241
+
242
+ def test_rejects_nil_add_hash
243
+ assert_raises ArgumentError do
244
+ Iri.new('http://google.com').add(nil)
245
+ end
246
+ end
247
+
248
+ def test_rejects_nil_over_hash
249
+ assert_raises ArgumentError do
250
+ Iri.new('http://google.com').over(nil)
251
+ end
252
+ end
253
+
254
+ def test_with_alias_for_add
255
+ assert_equal(
256
+ 'http://google.com?q=test&limit=10',
257
+ Iri.new('http://google.com').with(q: 'test', limit: 10).to_s
258
+ )
259
+ end
260
+
261
+ def test_without_alias_for_del
262
+ assert_equal(
263
+ 'http://google.com/?b=2',
264
+ Iri.new('http://google.com/?a=1&b=2&c=3').without(:a, :c).to_s
265
+ )
266
+ end
202
267
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Class Iri helps you build a URI and then modify its parts via a simple
14
13
  immutable fluent interface. It always returns a new object instead of changing the
@@ -27,6 +26,8 @@ files:
27
26
  - ".github/workflows/markdown-lint.yml"
28
27
  - ".github/workflows/pdd.yml"
29
28
  - ".github/workflows/rake.yml"
29
+ - ".github/workflows/reuse.yml"
30
+ - ".github/workflows/typos.yml"
30
31
  - ".github/workflows/xcop.yml"
31
32
  - ".github/workflows/yamllint.yml"
32
33
  - ".gitignore"
@@ -36,7 +37,9 @@ files:
36
37
  - Gemfile
37
38
  - Gemfile.lock
38
39
  - LICENSE.txt
40
+ - LICENSES/MIT.txt
39
41
  - README.md
42
+ - REUSE.toml
40
43
  - Rakefile
41
44
  - iri.gemspec
42
45
  - lib/iri.rb
@@ -49,7 +52,6 @@ licenses:
49
52
  - MIT
50
53
  metadata:
51
54
  rubygems_mfa_required: 'true'
52
- post_install_message:
53
55
  rdoc_options:
54
56
  - "--charset=UTF-8"
55
57
  require_paths:
@@ -65,8 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
67
  - !ruby/object:Gem::Version
66
68
  version: '0'
67
69
  requirements: []
68
- rubygems_version: 3.4.10
69
- signing_key:
70
+ rubygems_version: 3.6.7
70
71
  specification_version: 4
71
72
  summary: Simple Immutable Ruby URI Builder
72
73
  test_files: []