diff --git a/ci/Gemfile.all b/ci/Gemfile.all new file mode 100644 index 00000000..b52f7da0 --- /dev/null +++ b/ci/Gemfile.all @@ -0,0 +1,11 @@ +source :rubygems + +gem 'activerecord', '~> 3.0.0' +gem 'activesupport', '~> 3.0.0' +gem 'sqlite3-ruby' +gem 'mocha' +gem 'rufus-tokyo' +gem 'ffi' +gem 'ruby-cldr' +gem 'ruby2ruby' +gem 'ParseTree' diff --git a/ci/Gemfile.all.lock b/ci/Gemfile.all.lock new file mode 100644 index 00000000..b9746345 --- /dev/null +++ b/ci/Gemfile.all.lock @@ -0,0 +1,57 @@ +GEM + remote: http://rubygems.org/ + specs: + ParseTree (3.0.5) + RubyInline (>= 3.7.0) + sexp_processor (>= 3.0.0) + RubyInline (3.7.0) + hoe (>= 1.5.3) + activemodel (3.0.1) + activesupport (= 3.0.1) + builder (~> 2.1.2) + i18n (~> 0.4.1) + activerecord (3.0.1) + activemodel (= 3.0.1) + activesupport (= 3.0.1) + arel (~> 1.0.0) + tzinfo (~> 0.3.23) + activesupport (3.0.1) + arel (1.0.1) + activesupport (~> 3.0.0) + builder (2.1.2) + ffi (0.6.3) + rake (>= 0.8.7) + hoe (2.6.1) + rake (>= 0.8.7) + rubyforge (>= 2.0.4) + i18n (0.4.2) + json_pure (1.4.6) + mocha (0.9.8) + rake + rake (0.8.7) + ruby-cldr (0.0.1) + ruby2ruby (1.2.5) + ruby_parser (~> 2.0) + sexp_processor (~> 3.0) + ruby_parser (2.0.5) + sexp_processor (~> 3.0) + rubyforge (2.0.4) + json_pure (>= 1.1.7) + rufus-tokyo (1.0.7) + sexp_processor (3.0.5) + sqlite3-ruby (1.3.1) + tzinfo (0.3.23) + +PLATFORMS + ruby + +DEPENDENCIES + ParseTree + activerecord (~> 3.0.0) + activesupport (~> 3.0.0) + ffi + mocha + ruby-cldr + ruby2ruby + rufus-tokyo + sqlite3-ruby diff --git a/test/api/tests/interpolation.rb b/test/api/tests/interpolation.rb index 0c08cfe7..f72d5484 100644 --- a/test/api/tests/interpolation.rb +++ b/test/api/tests/interpolation.rb @@ -85,17 +85,30 @@ def interpolate(*args) interpolate(:default => euc_jp('こんにちは、%{name}さん!'), :name => 'ゆきひろ') end end - - # define_method "test interpolation: given a utf-8 translation and a euc-jp value it returns a translation in euc-jp" do - # assert_equal euc_jp('Hi ゆきひろ!'), interpolate(:default => 'Hi %{name}!', :name => euc_jp('ゆきひろ')) - # end - # - # TODO should better explain how this relates to the test above with the simpler utf-8 default string + define_method "test interpolation: given a utf-8 translation and a euc-jp value it raises Encoding::CompatibilityError" do assert_raise(Encoding::CompatibilityError) do interpolate(:default => 'こんにちは、%{name}さん!', :name => euc_jp('ゆきひろ')) end end + + define_method "test interpolation: ASCII strings in the backend should be encoded to UTF8 if interpolation options are in UTF8" do + I18n.backend.store_translations 'en', 'encoding' => ('%{who} let me go'.force_encoding("ASCII")) + result = I18n.t 'encoding', :who => "måmmå miå" + assert_equal Encoding::UTF_8, result.encoding + end + + define_method "test interpolation: UTF8 strings in the backend are still returned as UTF8 with ASCII interpolation" do + I18n.backend.store_translations 'en', 'encoding' => 'måmmå miå %{what}' + result = I18n.t 'encoding', :what => 'let me go'.force_encoding("ASCII") + assert_equal Encoding::UTF_8, result.encoding + end + + define_method "test interpolation: UTF8 strings in the backend are still returned as UTF8 even with numbers interpolation" do + I18n.backend.store_translations 'en', 'encoding' => '%{count} times: måmmå miå' + result = I18n.t 'encoding', :count => 3 + assert_equal Encoding::UTF_8, result.encoding + end end define_method "test interpolation: given a translations containing a reserved key it raises I18n::ReservedInterpolationKey" do diff --git a/test/backend/simple_test.rb b/test/backend/simple_test.rb index 3423988d..33d24778 100644 --- a/test/backend/simple_test.rb +++ b/test/backend/simple_test.rb @@ -79,25 +79,4 @@ def setup I18n.backend.reload! assert_equal I18n.backend.initialized?, false end - - # Encoding - if "string".respond_to?(:force_encoding) - test "ASCII strings in the backend should be encoded to UTF8 if interpolation options are in UTF8" do - I18n.backend.store_translations 'en', 'encoding' => ('%{who} let me go'.force_encoding("ASCII")) - result = I18n.t 'encoding', :who => "måmmå miå" - assert_equal Encoding::UTF_8, result.encoding - end - - test "UTF8 strings in the backend are still returned as UTF8" do - I18n.backend.store_translations 'en', 'encoding' => 'måmmå miå %{what}' - result = I18n.t 'encoding', :what => 'let me go'.force_encoding("ASCII") - assert_equal Encoding::UTF_8, result.encoding - end - - test "UTF8 strings in the backend are still returned as UTF8 even with numbers" do - I18n.backend.store_translations 'en', 'encoding' => '%{count} times: måmmå miå' - result = I18n.t 'encoding', :count => 3 - assert_equal Encoding::UTF_8, result.encoding - end - end end diff --git a/test/test_setup/options.rb b/test/test_setup/options.rb index ac66b427..4cee1215 100644 --- a/test/test_setup/options.rb +++ b/test/test_setup/options.rb @@ -19,12 +19,14 @@ def parse_options! @options[:adapter] = dep when :r23, :'rails-2.3.x' ENV['BUNDLE_GEMFILE'] = 'ci/Gemfile.rails-2.3.x' + when :r3, :'rails-3.0.x' + ENV['BUNDLE_GEMFILE'] = 'ci/Gemfile.rails-3.x' when :'no-rails' ENV['BUNDLE_GEMFILE'] = 'ci/Gemfile.no-rails' end end - ENV['BUNDLE_GEMFILE'] ||= 'ci/Gemfile.rails-3.x' + ENV['BUNDLE_GEMFILE'] ||= 'ci/Gemfile.all' end end end