aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorAlexey Gaziev <alex.gaziev@gmail.com>2012-04-29 13:42:40 +0400
committerAlexey Gaziev <alex.gaziev@gmail.com>2012-04-29 13:42:40 +0400
commit076536433f0eb3e684c8e7a571223c274c179b5e (patch)
treea51ec490b96b458aaa13effe92462795c14404f3 /activesupport/test/core_ext
parente6ab0d56cf5d376f4b351282c606ecc74e6fad9a (diff)
downloadrails-076536433f0eb3e684c8e7a571223c274c179b5e.tar.gz
rails-076536433f0eb3e684c8e7a571223c274c179b5e.tar.bz2
rails-076536433f0eb3e684c8e7a571223c274c179b5e.zip
Tests for regexp separator in String#truncate
https://github.com/rails/rails/commit/5a7513593f64e0ff7e4de1ee37bac5eeddfae270
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index 6c2828b74e..9010a4a716 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -279,6 +279,12 @@ class StringInflectionsTest < ActiveSupport::TestCase
assert_equal "Hello Big[...]", "Hello Big World!".truncate(15, :omission => "[...]", :separator => ' ')
end
+ def test_truncate_with_omission_and_regexp_seperator
+ assert_equal "Hello[...]", "Hello Big World!".truncate(13, :omission => "[...]", :separator => /\s/)
+ assert_equal "Hello Big[...]", "Hello Big World!".truncate(14, :omission => "[...]", :separator => /\s/)
+ assert_equal "Hello Big[...]", "Hello Big World!".truncate(15, :omission => "[...]", :separator => /\s/)
+ end
+
def test_truncate_multibyte
assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".force_encoding('UTF-8'),
"\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8').truncate(10)