Skip to content
Browse files

Merge pull request #112 from Bertg/master

Fixing override tests
  • Loading branch information...
2 parents c5d9e8c + e645504 commit da09d52c5aa67ddfe7571a59c68edd0bf4369700 @svenfuchs svenfuchs committed Oct 15, 2011
Showing with 15 additions and 9 deletions.
  1. +15 −9 test/api/override_test.rb
View
24 test/api/override_test.rb
@@ -13,29 +13,35 @@ def translate(*args)
module OverrideSignature
def translate(*args)
- args.first
+ args.first + args[1]
end
alias :t :translate
end
def setup
- I18n.backend = I18n::Backend::Simple.new
- I18n.extend OverrideInverse
+ @I18n = I18n.dup
+ @I18n.backend = I18n::Backend::Simple.new
super
end
test "make sure modules can overwrite I18n methods" do
- I18n.backend.store_translations('en', :foo => 'bar')
+ @I18n.extend OverrideInverse
+ @I18n.backend.store_translations('en', :foo => 'bar')
- assert_equal 'rab', I18n.translate(:foo, :locale => 'en')
- assert_equal 'rab', I18n.t(:foo, :locale => 'en')
- assert_equal 'rab', I18n.translate!(:foo, :locale => 'en')
- assert_equal 'rab', I18n.t!(:foo, :locale => 'en')
+ assert_equal 'rab', @I18n.translate(:foo, :locale => 'en')
+ assert_equal 'rab', @I18n.t(:foo, :locale => 'en')
+ assert_equal 'rab', @I18n.translate!(:foo, :locale => 'en')
+ assert_equal 'rab', @I18n.t!(:foo, :locale => 'en')
end
test "make sure modules can overwrite I18n signature" do
- assert I18n.translate("Hello", "Welcome message on home page", :tokenize => true) # tr8n example
+ exception = catch(:exception) do
+ @I18n.t('Hello', 'Welcome message on home page', :tokenize => true, :throw => true)
+ end
+ assert exception.message
+ @I18n.extend OverrideSignature
+ assert_equal 'HelloWelcome message on home page', @I18n.translate('Hello', 'Welcome message on home page', :tokenize => true) # tr8n example
end
end

0 comments on commit da09d52

Please sign in to comment.
Something went wrong with that request. Please try again.