From ce4b8501eb9585129fae5aee86e4027e6f2d2946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Mon, 9 Dec 2024 12:58:49 +0100 Subject: [PATCH 1/5] Add 'ruby-head' to test matrix --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index dfe29097..d61b0994 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - ruby_version: [3.3, 3.2, 3.1, '3.0', jruby] + ruby_version: [head, 3.3, 3.2, 3.1, '3.0', jruby] gemfile: - Gemfile - gemfiles/Gemfile.rails-6.0.x From a6b16dc5d4f64b37d2acdd51d8ae7f143a9dcdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Mon, 9 Dec 2024 10:23:00 +0100 Subject: [PATCH 2/5] Ruby 3.4 `Hash#inspect` compatibility. --- lib/i18n/tests/localization/procs.rb | 4 ++-- lib/i18n/tests/procs.rb | 18 +++++++++++------- test/backend/exceptions_test.rb | 2 +- test/backend/interpolation_compiler_test.rb | 2 +- test/i18n/exceptions_test.rb | 4 ++-- test/i18n/interpolate_test.rb | 2 +- test/locale/fallbacks_test.rb | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/i18n/tests/localization/procs.rb b/lib/i18n/tests/localization/procs.rb index 7db45d1d..2c5d8e15 100644 --- a/lib/i18n/tests/localization/procs.rb +++ b/lib/i18n/tests/localization/procs.rb @@ -34,7 +34,7 @@ module Procs test "localize Date: given a format that resolves to a Proc it calls the Proc with the object and extra options" do setup_time_proc_translations date = ::Date.new(2008, 3, 1) - assert_equal '[Sat, 01 Mar 2008, {:foo=>"foo"}]', I18n.l(date, :format => :proc, :foo => 'foo', :locale => :ru) + assert_equal %|[Sat, 01 Mar 2008, #{{:foo=>"foo"}}]|, I18n.l(date, :format => :proc, :foo => 'foo', :locale => :ru) end test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object" do @@ -46,7 +46,7 @@ module Procs test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object and extra options" do setup_time_proc_translations datetime = ::DateTime.new(2008, 3, 1, 6) - assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {:foo=>"foo"}]', I18n.l(datetime, :format => :proc, :foo => 'foo', :locale => :ru) + assert_equal %|[Sat, 01 Mar 2008 06:00:00 +00:00, #{{:foo=>"foo"}}]|, I18n.l(datetime, :format => :proc, :foo => 'foo', :locale => :ru) end test "localize Time: given a format that resolves to a Proc it calls the Proc with the object" do diff --git a/lib/i18n/tests/procs.rb b/lib/i18n/tests/procs.rb index db99c766..d377117d 100644 --- a/lib/i18n/tests/procs.rb +++ b/lib/i18n/tests/procs.rb @@ -5,34 +5,38 @@ module Tests module Procs test "lookup: given a translation is a proc it calls the proc with the key and interpolation values" do I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }) - assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo') + assert_equal %|[:a_lambda, #{{:foo=>"foo"}}]|, I18n.t(:a_lambda, :foo => 'foo') end test "lookup: given a translation is a proc it passes the interpolation values as keyword arguments" do I18n.backend.store_translations(:en, :a_lambda => lambda { |key, foo:, **| I18n::Tests::Procs.filter_args(key, foo: foo) }) - assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo') + assert_equal %|[:a_lambda, #{{:foo=>"foo"}}]|, I18n.t(:a_lambda, :foo => 'foo') end test "defaults: given a default is a Proc it calls it with the key and interpolation values" do proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } - assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') + assert_equal %|[nil, #{{:foo=>"foo"}}]|, I18n.t(nil, :default => proc, :foo => 'foo') end test "defaults: given a default is a key that resolves to a Proc it calls it with the key and interpolation values" do the_lambda = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } I18n.backend.store_translations(:en, :a_lambda => the_lambda) - assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo') - assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo') + assert_equal %|[:a_lambda, #{{:foo=>"foo"}}]|, I18n.t(nil, :default => :a_lambda, :foo => 'foo') + assert_equal %|[:a_lambda, #{{:foo=>"foo"}}]|, I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo') end test "interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } - assert_match %r(\[\{:foo=>#\}\]), I18n.t(nil, :default => '%{foo}', :foo => proc) + if RUBY_VERSION < "3.4" + assert_match %r(\[\{:foo=>#\}\]), I18n.t(nil, :default => '%{foo}', :foo => proc) + else + assert_match %r(\[\{foo: #\}\]), I18n.t(nil, :default => '%{foo}', :foo => proc) + end end test "interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do proc = lambda { |*args| "%{foo}: " + I18n::Tests::Procs.filter_args(*args) } - assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') + assert_equal %|foo: [nil, #{{:foo=>"foo"}}]|, I18n.t(nil, :default => proc, :foo => 'foo') end test "pluralization: given a key resolves to a Proc that returns valid data then pluralization still works" do diff --git a/test/backend/exceptions_test.rb b/test/backend/exceptions_test.rb index e19c8121..2973935c 100644 --- a/test/backend/exceptions_test.rb +++ b/test/backend/exceptions_test.rb @@ -31,6 +31,6 @@ def setup test "exceptions: MissingInterpolationArgument message includes missing key, provided keys and full string" do exception = I18n::MissingInterpolationArgument.new('key', {:this => 'was given'}, 'string') - assert_equal 'missing interpolation argument "key" in "string" ({:this=>"was given"} given)', exception.message + assert_equal %|missing interpolation argument "key" in "string" (#{{:this=>"was given"}} given)|, exception.message end end diff --git a/test/backend/interpolation_compiler_test.rb b/test/backend/interpolation_compiler_test.rb index 35acce38..68a634ca 100644 --- a/test/backend/interpolation_compiler_test.rb +++ b/test/backend/interpolation_compiler_test.rb @@ -88,7 +88,7 @@ def test_custom_missing_interpolation_argument_handler I18n.config.missing_interpolation_argument_handler = lambda do |key, values, string| "missing key is #{key}, values are #{values.inspect}, given string is '#{string}'" end - assert_equal %|first missing key is last, values are {:first=>"first"}, given string is '%{first} %{last}'|, + assert_equal %|first missing key is last, values are #{{:first=>"first"}.to_s}, given string is '%{first} %{last}'|, compile_and_interpolate('%{first} %{last}', :first => 'first') ensure I18n.config.missing_interpolation_argument_handler = old_handler diff --git a/test/i18n/exceptions_test.rb b/test/i18n/exceptions_test.rb index 771308d0..9029c17c 100644 --- a/test/i18n/exceptions_test.rb +++ b/test/i18n/exceptions_test.rb @@ -43,7 +43,7 @@ def test_invalid_locale_stores_locale test "InvalidPluralizationData message contains count, data and missing key" do force_invalid_pluralization_data do |exception| assert_match '1', exception.message - assert_match '{:other=>"bar"}', exception.message + assert_match %|#{{:other=>"bar"}}|, exception.message assert_match 'one', exception.message end end @@ -58,7 +58,7 @@ def test_invalid_locale_stores_locale test "MissingInterpolationArgument message contains the missing and given arguments" do force_missing_interpolation_argument do |exception| - assert_equal 'missing interpolation argument :bar in "%{bar}" ({:baz=>"baz"} given)', exception.message + assert_equal %|missing interpolation argument :bar in "%{bar}" (#{{:baz=>"baz"}.to_s} given)|, exception.message end end diff --git a/test/i18n/interpolate_test.rb b/test/i18n/interpolate_test.rb index 2d54090f..e9ef2c13 100644 --- a/test/i18n/interpolate_test.rb +++ b/test/i18n/interpolate_test.rb @@ -91,7 +91,7 @@ def teardown end test "String interpolation can use custom missing interpolation handler" do - assert_equal %|Masao missing key is last, values are {:first=>"Masao"}, given string is '%{first} %{last}'|, + assert_equal %|Masao missing key is last, values are #{{:first=>"Masao"}.to_s}, given string is '%{first} %{last}'|, I18n.interpolate("%{first} %{last}", :first => 'Masao') end end diff --git a/test/locale/fallbacks_test.rb b/test/locale/fallbacks_test.rb index c7218f38..d86041d2 100644 --- a/test/locale/fallbacks_test.rb +++ b/test/locale/fallbacks_test.rb @@ -179,6 +179,6 @@ def setup end test "#inspect" do - assert_equal('#[:"de-DE"]} @defaults=[:"en-US", :en]>', @fallbacks.inspect) + assert_equal(%|#[:"de-DE"]}} @defaults=[:"en-US", :en]>|, @fallbacks.inspect) end end From cb35bee3977e6ac10cebbf41a958dadc732bc832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 10 Dec 2024 17:13:57 +0100 Subject: [PATCH 3/5] Add `base64` / `mutex_m` dependencies for Rails 6.1 These are required for Ruby 3.4 support, which extracts `base64` / `mutex_m` into bundled gem. The maintained versions of Rails have the dependencies updated. --- gemfiles/Gemfile.rails-6.1.x | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gemfiles/Gemfile.rails-6.1.x b/gemfiles/Gemfile.rails-6.1.x index 6f67f785..43481a60 100644 --- a/gemfiles/Gemfile.rails-6.1.x +++ b/gemfiles/Gemfile.rails-6.1.x @@ -8,6 +8,8 @@ gem 'test_declarative', '0.0.6' gem 'rake' gem 'minitest', '~> 5.14' gem 'racc' +gem 'base64' +gem 'mutex_m' platforms :mri do gem 'oj' From bd5bd233da8ec7886f4b3eb3d751b7154b413e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 10 Dec 2024 17:32:19 +0100 Subject: [PATCH 4/5] Adjust the test matrix for Rails 8.1 Rails 8.1 requires Ruby 3.2 at minimum: ~~~ Bundler found conflicting requirements for the Ruby In Gemfile.rails-main: activesupport was resolved to 8.1.0.alpha, which depends on Ruby (>= 3.2.0) ~~~ --- .github/workflows/ruby.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index d61b0994..dfd75647 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -26,7 +26,9 @@ jobs: - gemfiles/Gemfile.rails-7.1.x - gemfiles/Gemfile.rails-main exclude: - # Ruby 3.0 is not supported by Rails main (requires at least Ruby 3.1) + # Rails main requires at least Ruby 3.2 + - ruby_version: '3.1' + gemfile: gemfiles/Gemfile.rails-main - ruby_version: '3.0' gemfile: gemfiles/Gemfile.rails-main # JRuby is not supported by Rails 7.0.x From 2af0b5b8400fead0fa406a5958c229254f1b1fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Wed, 11 Dec 2024 15:17:30 +0100 Subject: [PATCH 5/5] Add Rails 7.2 and 8.0 into test matrix. --- .github/workflows/ruby.yml | 15 +++++++++++++-- gemfiles/Gemfile.rails-7.2.x | 14 ++++++++++++++ gemfiles/Gemfile.rails-8.0.x | 14 ++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 gemfiles/Gemfile.rails-7.2.x create mode 100644 gemfiles/Gemfile.rails-8.0.x diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index dfd75647..265a1b60 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -24,17 +24,28 @@ jobs: - gemfiles/Gemfile.rails-6.1.x - gemfiles/Gemfile.rails-7.0.x - gemfiles/Gemfile.rails-7.1.x + - gemfiles/Gemfile.rails-7.2.x + - gemfiles/Gemfile.rails-8.0.x - gemfiles/Gemfile.rails-main exclude: - # Rails main requires at least Ruby 3.2 + # Rails 8+ requires at least Ruby 3.2 - ruby_version: '3.1' gemfile: gemfiles/Gemfile.rails-main - ruby_version: '3.0' gemfile: gemfiles/Gemfile.rails-main + - ruby_version: '3.1' + gemfile: gemfiles/Gemfile.rails-8.0.x + - ruby_version: '3.0' + gemfile: gemfiles/Gemfile.rails-8.0.x + # Rails 7.2.x requires at least Ruby 3.1 + - ruby_version: '3.0' + gemfile: gemfiles/Gemfile.rails-7.2.x # JRuby is not supported by Rails 7.0.x - ruby_version: jruby gemfile: gemfiles/Gemfile.rails-7.0.x - # JRuby is not supported by Rails main + # JRuby is not supported by Rails 8+ + - ruby_version: jruby + gemfile: gemfiles/Gemfile.rails-8.0.x - ruby_version: jruby gemfile: gemfiles/Gemfile.rails-main diff --git a/gemfiles/Gemfile.rails-7.2.x b/gemfiles/Gemfile.rails-7.2.x new file mode 100644 index 00000000..a4a00efe --- /dev/null +++ b/gemfiles/Gemfile.rails-7.2.x @@ -0,0 +1,14 @@ +source 'https://rubygems.org' + +gemspec :path => '..' + +gem 'activesupport', '~> 7.2' +gem 'mocha', '~> 2' +gem 'test_declarative', '0.0.6' +gem 'rake' +gem 'minitest', '~> 5.1' +gem 'racc' + +platforms :mri do + gem 'oj' +end diff --git a/gemfiles/Gemfile.rails-8.0.x b/gemfiles/Gemfile.rails-8.0.x new file mode 100644 index 00000000..16d4dba4 --- /dev/null +++ b/gemfiles/Gemfile.rails-8.0.x @@ -0,0 +1,14 @@ +source 'https://rubygems.org' + +gemspec :path => '..' + +gem 'activesupport', '~> 8.0' +gem 'mocha', '~> 2' +gem 'test_declarative', '0.0.6' +gem 'rake' +gem 'minitest', '~> 5.1' +gem 'racc' + +platforms :mri do + gem 'oj' +end