diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index e1525d6170..19a30f1730 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -168,6 +168,23 @@ class StringInflectionsTest < Test::Unit::TestCase assert !s.end_with?('el') end + def test_string_squish + original = %{ A string with tabs(\t\t), newlines(\n\n), and + many spaces( ). } + + expected = "A string with tabs( ), newlines( ), and many spaces( )." + + # Make sure squish returns what we expect: + assert_equal original.squish, expected + # But doesn't modify the original string: + assert_not_equal original, expected + + # Make sure squish! returns what we expect: + assert_equal original.squish!, expected + # And changes the original string: + assert_equal original, expected + end + if RUBY_VERSION < '1.9' def test_each_char_with_utf8_string_when_kcode_is_utf8 old_kcode, $KCODE = $KCODE, 'UTF8' |