diff options
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/multibyte.rb | 5 | ||||
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb index 3bf79bc7e1..a4caa83b74 100644 --- a/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb @@ -54,7 +54,10 @@ module ActiveSupport #:nodoc: end unless '1.8.7 and later'.respond_to?(:chars) - alias chars mb_chars + def chars + ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller) + mb_chars + end end else def mb_chars #:nodoc diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index fe5ce276c5..b086c957fe 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -226,6 +226,12 @@ class CoreExtStringMultibyteTest < Test::Unit::TestCase def test_core_ext_adds_chars assert UNICODE_STRING.respond_to?(:chars) end + + def test_chars_warns_about_deprecation + assert_deprecated("String#chars") do + ''.chars + end + end end if RUBY_VERSION < '1.9' |