aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/multibyte_chars_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/multibyte_chars_test.rb')
-rw-r--r--activesupport/test/multibyte_chars_test.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb
index 006e5c5927..41248cccb6 100644
--- a/activesupport/test/multibyte_chars_test.rb
+++ b/activesupport/test/multibyte_chars_test.rb
@@ -7,6 +7,7 @@ class String
def __method_for_multibyte_testing_with_integer_result; 1; end
def __method_for_multibyte_testing; 'result'; end
def __method_for_multibyte_testing!; 'result'; end
+ def __method_for_multibyte_testing_that_returns_nil!; end
end
class MultibyteCharsTest < Test::Unit::TestCase
@@ -36,11 +37,15 @@ class MultibyteCharsTest < Test::Unit::TestCase
assert_not_equal @chars.object_id, @chars.__method_for_multibyte_testing.object_id
end
- def test_forwarded_bang_method_calls_should_return_the_original_chars_instance
+ def test_forwarded_bang_method_calls_should_return_the_original_chars_instance_when_result_is_not_nil
assert_kind_of @proxy_class, @chars.__method_for_multibyte_testing!
assert_equal @chars.object_id, @chars.__method_for_multibyte_testing!.object_id
end
+ def test_forwarded_bang_method_calls_should_return_nil_when_result_is_nil
+ assert_nil @chars.__method_for_multibyte_testing_that_returns_nil!
+ end
+
def test_methods_are_forwarded_to_wrapped_string_for_byte_strings
assert_equal BYTE_STRING.class, BYTE_STRING.mb_chars.class
end
@@ -117,10 +122,11 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
assert_equal 'こに わ', @chars
end
- %w{capitalize downcase lstrip reverse rstrip strip upcase}.each do |method|
+ %w{capitalize downcase lstrip reverse rstrip upcase}.each do |method|
class_eval(<<-EOTESTS)
- def test_#{method}_bang_should_return_self
- assert_equal @chars.object_id, @chars.send("#{method}!").object_id
+ def test_#{method}_bang_should_return_self_when_modifying_wrapped_string
+ chars = ' él piDió Un bUen café '
+ assert_equal chars.object_id, chars.send("#{method}!").object_id
end
def test_#{method}_bang_should_change_wrapped_string