diff options
author | Ricardo Díaz <ricardotk002@gmail.com> | 2017-08-02 00:10:36 -0500 |
---|---|---|
committer | Ricardo Díaz <ricardotk002@gmail.com> | 2017-08-02 00:41:09 -0500 |
commit | 1d65185c90b0604d1b0a3ff3e9b53c3d6361dd3e (patch) | |
tree | 1062e04c189cf160eb0a45f21b7305135fcdd5b5 /activesupport/test/core_ext | |
parent | f9a43f28c087f8ffd35ff7c33a60c938b60f2be2 (diff) | |
download | rails-1d65185c90b0604d1b0a3ff3e9b53c3d6361dd3e.tar.gz rails-1d65185c90b0604d1b0a3ff3e9b53c3d6361dd3e.tar.bz2 rails-1d65185c90b0604d1b0a3ff3e9b53c3d6361dd3e.zip |
Update String#camelize to provide feedback when wrong option is passed
String#camelize was returning nil without any feedback when an
invalid option was passed as parameter. This update makes the method
to raises an ArgumentError when the option passed is invalid, similar
to what Ruby does for String#downcase (and others) in 2.4.1.
https://ruby-doc.org/core-2.4.1/String.html#method-i-downcase
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 0afff5aa50..9fd6d8ac0f 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -108,6 +108,13 @@ class StringInflectionsTest < ActiveSupport::TestCase assert_equal("capital", "Capital".camelize(:lower)) end + def test_camelize_invalid_option + e = assert_raise ArgumentError do + "Capital".camelize(nil) + end + assert_equal("Invalid option, use either :upper or :lower.", e.message) + end + def test_dasherize UnderscoresToDashes.each do |underscored, dasherized| assert_equal(dasherized, underscored.dasherize) |