diff options
| author | hukl <contact@smyck.org> | 2010-01-14 22:21:43 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2010-01-14 22:21:43 +0100 |
| commit | 57d1382013c85a7b11ac8ce5e683f6006b12b328 (patch) | |
| tree | 19646c4fa5952fa1cf0a2c874952affa346373f1 /vendor/plugins/globalize2/test/backends/pluralizing_test.rb | |
| parent | 1b86bf5f2e35d1820bfa32d979bcc2d9ff9a9a8e (diff) | |
Updated globalize2 to latest version. Modified existing code accoringly
Diffstat (limited to 'vendor/plugins/globalize2/test/backends/pluralizing_test.rb')
| -rw-r--r-- | vendor/plugins/globalize2/test/backends/pluralizing_test.rb | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/vendor/plugins/globalize2/test/backends/pluralizing_test.rb b/vendor/plugins/globalize2/test/backends/pluralizing_test.rb deleted file mode 100644 index 7445e3ff..00000000 --- a/vendor/plugins/globalize2/test/backends/pluralizing_test.rb +++ /dev/null | |||
| @@ -1,63 +0,0 @@ | |||
| 1 | require File.join( File.dirname(__FILE__), '..', 'test_helper' ) | ||
| 2 | require 'globalize/backend/pluralizing' | ||
| 3 | |||
| 4 | class PluralizingTest < ActiveSupport::TestCase | ||
| 5 | def setup | ||
| 6 | @backend = Globalize::Backend::Pluralizing.new | ||
| 7 | @cz_pluralizer = lambda{|c| c == 1 ? :one : (2..4).include?(c) ? :few : :other } | ||
| 8 | end | ||
| 9 | |||
| 10 | test "#pluralizer returns the pluralizer for a given locale if defined" do | ||
| 11 | assert_instance_of Proc, @backend.pluralizer(:en) | ||
| 12 | end | ||
| 13 | |||
| 14 | test "#pluralizer returns the default pluralizer if no pluralizer is defined for the given locale" do | ||
| 15 | assert_equal @backend.pluralizer(:en), @backend.pluralizer(:de) | ||
| 16 | end | ||
| 17 | |||
| 18 | test "#add_pluralizer allows to store a pluralizer per locale" do | ||
| 19 | assert_nothing_raised { @backend.add_pluralizer(:cz, @cz_pluralizer) } | ||
| 20 | assert_equal @cz_pluralizer, @backend.pluralizer(:cz) | ||
| 21 | end | ||
| 22 | |||
| 23 | end | ||
| 24 | |||
| 25 | class PluralizePluralizingTest < ActiveSupport::TestCase | ||
| 26 | def setup | ||
| 27 | @backend = Globalize::Backend::Pluralizing.new | ||
| 28 | @cz_pluralizer = lambda{|c| c == 1 ? :one : (2..4).include?(c) ? :few : :other } | ||
| 29 | @backend.store_translations :en, :foo => {:one => 'one en foo', :other => 'many en foos'} | ||
| 30 | @backend.store_translations :cz, :foo => {:one => 'one cz foo', :few => 'few cz foos', :other => 'many cz foos'} | ||
| 31 | end | ||
| 32 | |||
| 33 | test "looks up the :one translation when count is 1" do | ||
| 34 | assert_equal 'one en foo', @backend.translate(:en, :foo, :count => 1) | ||
| 35 | end | ||
| 36 | |||
| 37 | test "looks up the :other translation when count is 2" do | ||
| 38 | assert_equal 'many en foos', @backend.translate(:en, :foo, :count => 2) | ||
| 39 | end | ||
| 40 | end | ||
| 41 | |||
| 42 | class CzPluralizingTest < ActiveSupport::TestCase | ||
| 43 | def setup | ||
| 44 | @backend = Globalize::Backend::Pluralizing.new | ||
| 45 | @cz_pluralizer = lambda{|c| c == 1 ? :one : (2..4).include?(c) ? :few : :other } | ||
| 46 | @backend.store_translations :en, :foo => {:one => 'one en foo', :other => 'many en foos'} | ||
| 47 | @backend.store_translations :cz, :foo => {:one => 'one cz foo', :few => 'few cz foos', :other => 'many cz foos'} | ||
| 48 | @backend.add_pluralizer(:cz, @cz_pluralizer) | ||
| 49 | end | ||
| 50 | |||
| 51 | test "looks up the :one translation when count is 1 (:cz)" do | ||
| 52 | assert_equal 'one cz foo', @backend.translate(:cz, :foo, :count => 1) | ||
| 53 | end | ||
| 54 | |||
| 55 | test "looks up the :few translation when count is 2 (:cz)" do | ||
| 56 | assert_equal 'few cz foos', @backend.translate(:cz, :foo, :count => 2) | ||
| 57 | end | ||
| 58 | |||
| 59 | test "looks up the :other translation when count is 5 (:cz)" do | ||
| 60 | assert_equal 'many cz foos', @backend.translate(:cz, :foo, :count => 5) | ||
| 61 | end | ||
| 62 | |||
| 63 | end | ||
