iri 0.10.0 → 0.11.1

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.
@@ -38,9 +19,9 @@ class IriTest < Minitest::Test
38
19
  .over(q: 'books about tennis', limit: 10)
39
20
  .scheme('https')
40
21
  .host('localhost')
41
- .port('443')
22
+ .port(8080)
42
23
  .to_s
43
- assert_equal('https://localhost:443/?q=books+about+tennis&limit=10', url)
24
+ assert_equal('https://localhost:8080/?q=books+about+tennis&limit=10', url)
44
25
  end
45
26
 
46
27
  def test_converts_to_uri
@@ -50,6 +31,13 @@ class IriTest < Minitest::Test
50
31
  )
51
32
  end
52
33
 
34
+ def test_hides_https_port_number
35
+ assert_equal(
36
+ 'https://google.com/abc',
37
+ Iri.new('https://google.com').port(443).append('abc').to_s
38
+ )
39
+ end
40
+
53
41
  def test_converts_to_local
54
42
  {
55
43
  'http://localhost:9292/' => '/',
@@ -175,7 +163,7 @@ class IriTest < Minitest::Test
175
163
  def test_appends_path
176
164
  assert_equal(
177
165
  'http://google/a/b/z+%2F+7/42?x=3',
178
- Iri.new('http://google/a/b?x=3').append('z / 7').append(42).to_s
166
+ Iri.new('http://google/a/b?x=3').append('z / 7').append(42.to_s).to_s
179
167
  )
180
168
  end
181
169
 
@@ -187,10 +175,6 @@ class IriTest < Minitest::Test
187
175
  end
188
176
 
189
177
  def test_appends_empty_path
190
- assert_equal(
191
- 'http://google.com/hello/',
192
- Iri.new('http://google.com/hello').append('').append('').to_s
193
- )
194
178
  assert_equal(
195
179
  'http://google.com/test',
196
180
  Iri.new('http://google.com/hello').cut.append('test').to_s
@@ -203,4 +187,84 @@ class IriTest < Minitest::Test
203
187
  Iri.new('http://google/?a=1&b=2&c=3&a=33').over(a: 'hey').to_s
204
188
  )
205
189
  end
190
+
191
+ def test_rejects_nil_uri
192
+ assert_raises ArgumentError do
193
+ Iri.new(nil)
194
+ end
195
+ end
196
+
197
+ def test_rejects_nil_scheme
198
+ assert_raises ArgumentError do
199
+ Iri.new('http://google.com').scheme(nil)
200
+ end
201
+ end
202
+
203
+ def test_rejects_nil_host
204
+ assert_raises ArgumentError do
205
+ Iri.new('http://google.com').host(nil)
206
+ end
207
+ end
208
+
209
+ def test_rejects_nil_port
210
+ assert_raises ArgumentError do
211
+ Iri.new('http://google.com').port(nil)
212
+ end
213
+ end
214
+
215
+ def test_rejects_nil_path
216
+ assert_raises ArgumentError do
217
+ Iri.new('http://google.com').path(nil)
218
+ end
219
+ end
220
+
221
+ def test_rejects_nil_fragment
222
+ assert_raises ArgumentError do
223
+ Iri.new('http://google.com').fragment(nil)
224
+ end
225
+ end
226
+
227
+ def test_rejects_nil_query
228
+ assert_raises ArgumentError do
229
+ Iri.new('http://google.com').query(nil)
230
+ end
231
+ end
232
+
233
+ def test_rejects_nil_cut_path
234
+ assert_raises ArgumentError do
235
+ Iri.new('http://google.com/foo').cut(nil)
236
+ end
237
+ end
238
+
239
+ def test_rejects_nil_append_part
240
+ assert_raises ArgumentError do
241
+ Iri.new('http://google.com').append(nil)
242
+ end
243
+ end
244
+
245
+ def test_rejects_nil_add_hash
246
+ assert_raises ArgumentError do
247
+ Iri.new('http://google.com').add(nil)
248
+ end
249
+ end
250
+
251
+ def test_rejects_nil_over_hash
252
+ assert_raises ArgumentError do
253
+ Iri.new('http://google.com').over(nil)
254
+ end
255
+ end
256
+
257
+ def test_with_alias_for_add
258
+ assert_equal(
259
+ 'http://google.com?q=test&limit=10',
260
+ Iri.new('http://google.com').with(q: 'test', limit: 10).to_s
261
+ )
262
+ end
263
+
264
+ def test_without_alias_for_del
265
+ assert_equal(
266
+ 'http://google.com/?b=2',
267
+ Iri.new('http://google.com/?a=1&b=2&c=3').without(:a, :c).to_s
268
+ )
269
+ end
206
270
  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.10.0
4
+ version: 0.11.1
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: []