aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/string_ext_test.rb
diff options
context:
space:
mode:
authorclaudiob <claudiob@gmail.com>2013-11-06 12:57:21 -0800
committerclaudiob <claudiob@gmail.com>2013-11-06 13:03:46 -0800
commitc61544c7818f109c132fcad9db73d43216417535 (patch)
tree63356431e4898a820f8f8ff8f7103b2f2c36dba7 /activesupport/test/core_ext/string_ext_test.rb
parent256ae7dec5626620eb5a064f50931e1d9317b2a4 (diff)
downloadrails-c61544c7818f109c132fcad9db73d43216417535.tar.gz
rails-c61544c7818f109c132fcad9db73d43216417535.tar.bz2
rails-c61544c7818f109c132fcad9db73d43216417535.zip
Add +capitalize+ option to Inflector.humanize
So strings can be humanized without being capitalized: 'employee_salary'.humanize # => "Employee salary" 'employee_salary'.humanize(capitalize: false) # => "employee salary"
Diffstat (limited to 'activesupport/test/core_ext/string_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index 3cb66d4eec..20e3d4802e 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -155,6 +155,12 @@ class StringInflectionsTest < ActiveSupport::TestCase
end
end
+ def test_humanize_without_capitalize
+ UnderscoreToHumanWithoutCapitalize.each do |underscore, human|
+ assert_equal(human, underscore.humanize(capitalize: false))
+ end
+ end
+
def test_ord
assert_equal 97, 'a'.ord
assert_equal 97, 'abc'.ord
@@ -270,7 +276,7 @@ class StringInflectionsTest < ActiveSupport::TestCase
def test_truncate_should_not_be_html_safe
assert !"Hello World!".truncate(12).html_safe?
end
-
+
def test_remove
assert_equal "Summer", "Fast Summer".remove(/Fast /)
assert_equal "Summer", "Fast Summer".remove!(/Fast /)