0
@@ -110,6 +110,23 @@ class InflectorTest < Test::Unit::TestCase
0
+ def test_humanize_by_rule
0
+ ActiveSupport::Inflector.inflections do |inflect|
0
+ inflect.human(/_cnt$/i, '\1_count')
0
+ inflect.human(/^prefx_/i, '\1')
0
+ assert_equal("Jargon count", ActiveSupport::Inflector.humanize("jargon_cnt"))
0
+ assert_equal("Request", ActiveSupport::Inflector.humanize("prefx_request"))
0
+ def test_humanize_by_string
0
+ ActiveSupport::Inflector.inflections do |inflect|
0
+ inflect.human("col_rpted_bugs", "Reported bugs")
0
+ assert_equal("Reported bugs", ActiveSupport::Inflector.humanize("col_rpted_bugs"))
0
+ assert_equal("Col rpted bugs", ActiveSupport::Inflector.humanize("COL_rpted_bugs"))
0
assert_nothing_raised { assert_equal Ace::Base::Case, ActiveSupport::Inflector.constantize("Ace::Base::Case") }
0
assert_nothing_raised { assert_equal Ace::Base::Case, ActiveSupport::Inflector.constantize("::Ace::Base::Case") }
0
@@ -148,7 +165,7 @@ class InflectorTest < Test::Unit::TestCase
0
- %w{plurals singulars uncountables
}.each do |inflection_type|
0
+ %w{plurals singulars uncountables
humans}.each do |inflection_type|
0
def test_clear_#{inflection_type}
0
cached_values = ActiveSupport::Inflector.inflections.#{inflection_type}
0
@@ -160,25 +177,29 @@ class InflectorTest < Test::Unit::TestCase
0
- cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables
0
+ cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables
, ActiveSupport::Inflector.inflections.humans0
ActiveSupport::Inflector.inflections.clear :all
0
assert ActiveSupport::Inflector.inflections.plurals.empty?
0
assert ActiveSupport::Inflector.inflections.singulars.empty?
0
assert ActiveSupport::Inflector.inflections.uncountables.empty?
0
+ assert ActiveSupport::Inflector.inflections.humans.empty?
0
ActiveSupport::Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
0
ActiveSupport::Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
0
ActiveSupport::Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
0
+ ActiveSupport::Inflector.inflections.instance_variable_set :@humans, cached_values[3]
0
def test_clear_with_default
0
- cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables
0
+ cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables
, ActiveSupport::Inflector.inflections.humans0
ActiveSupport::Inflector.inflections.clear
0
assert ActiveSupport::Inflector.inflections.plurals.empty?
0
assert ActiveSupport::Inflector.inflections.singulars.empty?
0
assert ActiveSupport::Inflector.inflections.uncountables.empty?
0
+ assert ActiveSupport::Inflector.inflections.humans.empty?
0
ActiveSupport::Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
0
ActiveSupport::Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
0
ActiveSupport::Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
0
+ ActiveSupport::Inflector.inflections.instance_variable_set :@humans, cached_values[3]
0
Irregularities.each do |irregularity|
0
@@ -217,7 +238,7 @@ class InflectorTest < Test::Unit::TestCase
0
- { :singulars => :singular, :plurals => :plural, :uncountables => :uncountable
}.each do |scope, method|
0
+ { :singulars => :singular, :plurals => :plural, :uncountables => :uncountable
, :humans => :human }.each do |scope, method|
0
ActiveSupport::Inflector.inflections do |inflect|
0
define_method("test_clear_inflections_with_#{scope}") do
Comments
No one has commented yet.