Skip to content

Commit 1d684cd

Browse files
committed
Fix last tests
1 parent a90abaf commit 1d684cd

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

CHANGELOG.md

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
# Changelog
22

3-
## NEXT / YYYY-MM-DD
3+
## 4.0.0 / YYYY-MM-DD
44

5-
- 1 deprecation:
5+
- The minimum supported Ruby version for mime-types 4 is Ruby 3.2. All backport
6+
support for older versions of Ruby have been removed.
67

7-
- Deprecated `MIME::Type#priority_compare`. In a future release, this will be
8-
will be renamed to `MIME::Type#<=>`. This method is used in tight loops, so
9-
there is no warning message for either `MIME::Type#priority_compare` or
10-
`MIME::Type#<=>`.
8+
## 3.7.0 / YYYY-MM-DD
119

12-
- 1 enhancement:
10+
- Deprecated `MIME::Type#priority_compare`. In a future release, this will be
11+
will be renamed to `MIME::Type#<=>`. This method is used in tight loops, so
12+
there is no warning message for either `MIME::Type#priority_compare` or
13+
`MIME::Type#<=>`.
1314

14-
- Improved the performance of sorting by eliminating the complex comparison
15-
flow from `MIME::Type#priority_compare`. The old version shows under 600
16-
i/s, and the new version shows over 900 i/s. In sorting the full set of MIME
17-
data, there are three differences between the old and new versions; after
18-
comparison, these differences are considered acceptable.
15+
- Improved the performance of sorting by eliminating the complex comparison flow
16+
from `MIME::Type#priority_compare`. The old version shows under 600 i/s, and
17+
the new version shows over 900 i/s. In sorting the full set of MIME data,
18+
there are three differences between the old and new versions; after
19+
comparison, these differences are considered acceptable.
1920

20-
- 1 bug fix:
21-
22-
- Simplified the default compare implementation (`MIME::Type#<=>`) to use the
23-
new `MIME::Type#priority_compare` operation and simplify the fallback to
24-
`String` comparison. This _may_ result in exceptions where there had been
25-
none, as explicit support for several special values (which should have
26-
caused errors in any case) have been removed.
21+
- Simplified the default compare implementation (`MIME::Type#<=>`) to use the
22+
new `MIME::Type#priority_compare` operation and simplify the fallback to
23+
`String` comparison. This _may_ result in exceptions where there had been
24+
none, as explicit support for several special values (which should have caused
25+
errors in any case) have been removed.
2726

2827
## 3.6.2 / 2025-03-25
2928

Rakefile

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ require "rubygems"
22
require "hoe"
33
require "rake/clean"
44
require "minitest"
5+
require "minitest/test_task"
56

67
Hoe.plugin :halostatue
78
Hoe.plugin :rubygems
@@ -10,6 +11,7 @@ Hoe.plugins.delete :debug
1011
Hoe.plugins.delete :newb
1112
Hoe.plugins.delete :publish
1213
Hoe.plugins.delete :signing
14+
Hoe.plugins.delete :test
1315

1416
spec = Hoe.spec "mime-types" do
1517
developer("Austin Ziegler", "[email protected]")
@@ -65,6 +67,8 @@ Minitest::TestTask.create :coverage do |t|
6567
RUBY
6668
end
6769

70+
task default: :test
71+
6872
namespace :benchmark do
6973
task :support do
7074
%w[lib support].each { |path|

mime-types.gemspec

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
66
s.version = "3.6.2".freeze
77

88
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9-
s.metadata = { "bug_tracker_uri" => "https://github.com/mime-types/ruby-mime-types/issues", "changelog_uri" => "https://github.com/mime-types/ruby-mime-types/blob/master/History.md", "homepage_uri" => "https://github.com/mime-types/ruby-mime-types/", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/mime-types/ruby-mime-types/" } if s.respond_to? :metadata=
9+
s.metadata = { "bug_tracker_uri" => "https://github.com/mime-types/ruby-mime-types/issues", "changelog_uri" => "https://github.com/mime-types/ruby-mime-types/blob/main/CHANGELOG.md", "homepage_uri" => "https://github.com/mime-types/ruby-mime-types/", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/mime-types/ruby-mime-types/" } if s.respond_to? :metadata=
1010
s.require_paths = ["lib".freeze]
1111
s.authors = ["Austin Ziegler".freeze]
12-
s.date = "2025-03-24"
12+
s.date = "2025-04-04"
1313
s.description = "The mime-types library provides a library and registry for information about\nMIME content type definitions. It can be used to determine defined filename\nextensions for MIME types, or to use filename extensions to look up the likely\nMIME type definitions.\n\nVersion 3.0 is a major release that requires Ruby 2.0 compatibility and removes\ndeprecated functions. The columnar registry format introduced in 2.6 has been\nmade the primary format; the registry data has been extracted from this library\nand put into {mime-types-data}[https://github.com/mime-types/mime-types-data].\nAdditionally, mime-types is now licensed exclusively under the MIT licence and\nthere is a code of conduct in effect. There are a number of other smaller\nchanges described in the History file.".freeze
1414
s.email = ["[email protected]".freeze]
1515
s.extra_rdoc_files = ["CHANGELOG.md".freeze, "CODE_OF_CONDUCT.md".freeze, "CONTRIBUTING.md".freeze, "CONTRIBUTORS.md".freeze, "LICENCE.md".freeze, "Manifest.txt".freeze, "README.md".freeze, "SECURITY.md".freeze]
@@ -18,20 +18,21 @@ Gem::Specification.new do |s|
1818
s.licenses = ["MIT".freeze]
1919
s.rdoc_options = ["--main".freeze, "README.md".freeze]
2020
s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze)
21-
s.rubygems_version = "3.6.2".freeze
21+
s.rubygems_version = "3.6.6".freeze
2222
s.summary = "The mime-types library provides a library and registry for information about MIME content type definitions".freeze
2323

2424
s.specification_version = 4
2525

2626
s.add_runtime_dependency(%q<mime-types-data>.freeze, ["~> 3.2015".freeze])
2727
s.add_runtime_dependency(%q<logger>.freeze, [">= 0".freeze])
28-
s.add_development_dependency(%q<minitest>.freeze, ["~> 5.25".freeze])
2928
s.add_development_dependency(%q<hoe>.freeze, ["~> 4.0".freeze])
3029
s.add_development_dependency(%q<hoe-halostatue>.freeze, ["~> 2.0".freeze])
3130
s.add_development_dependency(%q<hoe-rubygems>.freeze, ["~> 1.0".freeze])
31+
s.add_development_dependency(%q<minitest>.freeze, ["~> 5.0".freeze])
3232
s.add_development_dependency(%q<minitest-autotest>.freeze, ["~> 1.0".freeze])
3333
s.add_development_dependency(%q<minitest-focus>.freeze, ["~> 1.0".freeze])
3434
s.add_development_dependency(%q<minitest-hooks>.freeze, ["~> 1.4".freeze])
35-
s.add_development_dependency(%q<rake>.freeze, [">= 10.0".freeze, "< 14.0".freeze])
35+
s.add_development_dependency(%q<rake>.freeze, [">= 10.0".freeze, "< 14".freeze])
36+
s.add_development_dependency(%q<rdoc>.freeze, [">= 0.0".freeze])
3637
s.add_development_dependency(%q<standard>.freeze, ["~> 1.0".freeze])
3738
end

test/minitest_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
$debug = false
4+
35
gem "minitest"
46
require "minitest/focus"
57
require "minitest/hooks"

test/test_mime_type.rb

+10-16
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,13 @@ def mime_type(content_type)
322322

323323
describe "#priority_compare" do
324324
def priority(type)
325-
"#{type} (#{("%08b" % type.__sort_priority).chars.join(" ")})"
325+
priority = "OpRceXtN"
326+
.chars
327+
.zip(("%08b" % type.__sort_priority).chars)
328+
.map { |e| e.join(":") }
329+
.join(" ")
330+
331+
"#{type} (#{priority} / #{type.__sort_priority})"
326332
end
327333

328334
def assert_priority_less(left, right)
@@ -340,7 +346,7 @@ def assert_priority_more(left, right)
340346
def assert_priority(left, middle, right)
341347
assert_priority_less left, right
342348
assert_priority_same left, middle
343-
assert_priority_more right, left
349+
assert_priority_more right, middle
344350
end
345351

346352
let(:text_1) { mime_type("content-type" => "text/1") }
@@ -361,8 +367,8 @@ def assert_priority(left, middle, right)
361367
end
362368

363369
it "sorts provisional types higher than non-provisional types" do
364-
text_1.provisional = text_1p.provisional = true
365-
text_1b = mime_type(text_1) { |t| t.provisional = false }
370+
text_1.provisional = text_1p.provisional = false
371+
text_1b = mime_type(text_1) { |t| t.provisional = true }
366372

367373
assert_priority text_1, text_1p, text_1b
368374
end
@@ -381,18 +387,6 @@ def assert_priority(left, middle, right)
381387
assert_priority text_1, text_1p, text_1b
382388
end
383389

384-
it "sorts (5) based on the use-instead value" do
385-
text_1.obsolete = text_1p.obsolete = true
386-
text_1.use_instead = text_1p.use_instead = "abc/xyz"
387-
text_1b = mime_type(text_1) { |t| t.use_instead = nil }
388-
389-
assert_priority text_1, text_1p, text_1b
390-
391-
text_1b.use_instead = "abc/zzz"
392-
393-
assert_priority text_1, text_1p, text_1b
394-
end
395-
396390
it "sorts based on extensions (more extensions sort lower)" do
397391
text_1.extensions = ["foo", "bar"]
398392
text_2.extensions = ["foo"]

0 commit comments

Comments
 (0)