diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index dfe29097..265a1b60 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -17,22 +17,35 @@ 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 - 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: - # Ruby 3.0 is not supported by Rails main (requires at least Ruby 3.1) + # 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-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' 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 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