aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2012-04-29 03:08:41 -0700
committerJosé Valim <jose.valim@gmail.com>2012-04-29 03:08:41 -0700
commit0b019cc3b821eb362ef3f75f4bc16727c1f23fa6 (patch)
treed3cba3fd8cf16eca69d9756231faf21d0a6f61fc /activesupport/lib
parent7a80b69e00f68e673c6ceb5cc684aa9196ed3d9f (diff)
parent076536433f0eb3e684c8e7a571223c274c179b5e (diff)
downloadrails-0b019cc3b821eb362ef3f75f4bc16727c1f23fa6.tar.gz
rails-0b019cc3b821eb362ef3f75f4bc16727c1f23fa6.tar.bz2
rails-0b019cc3b821eb362ef3f75f4bc16727c1f23fa6.zip
Merge pull request #6044 from gazay/tests_for_string_truncate_w_regexp_separator
Tests for regexp separator in String#truncate
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/string/filters.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb
index 9ef410c38b..32a37296d5 100644
--- a/activesupport/lib/active_support/core_ext/string/filters.rb
+++ b/activesupport/lib/active_support/core_ext/string/filters.rb
@@ -25,11 +25,14 @@ class String
# 'Once upon a time in a world far far away'.truncate(27)
# # => "Once upon a time in a wo..."
#
- # Pass a <tt>:separator</tt> to truncate +text+ at a natural break:
+ # Pass a string or regexp <tt>:separator</tt> to truncate +text+ at a natural break:
#
# 'Once upon a time in a world far far away'.truncate(27, :separator => ' ')
# # => "Once upon a time in a..."
#
+ # 'Once upon a time in a world far far away'.truncate(27, :separator => /\s/)
+ # # => "Once upon a time in a..."
+ #
# The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...")
# for a total length not exceeding <tt>:length</tt>:
#