aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2019-07-29 13:33:03 +0900
committerAkira Matsuda <ronnie@dio.jp>2019-07-29 14:17:36 +0900
commit381e8cb67abec7d2ceb812fde587d924667de122 (patch)
treeebfaffe8ee31c7223963d7221b63eef1a7957d95 /activesupport
parentd55dea5ef1cde3172d83f12a7ded96a9603dcaa9 (diff)
downloadrails-381e8cb67abec7d2ceb812fde587d924667de122.tar.gz
rails-381e8cb67abec7d2ceb812fde587d924667de122.tar.bz2
rails-381e8cb67abec7d2ceb812fde587d924667de122.zip
Add AS::Multibyte::Chars#match?
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb2
-rw-r--r--activesupport/test/multibyte_chars_test.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index 2ba3936cae..868cb70423 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -48,7 +48,7 @@ module ActiveSupport #:nodoc:
alias to_s wrapped_string
alias to_str wrapped_string
- delegate :<=>, :=~, :acts_like_string?, to: :wrapped_string
+ delegate :<=>, :=~, :match?, :acts_like_string?, to: :wrapped_string
# Creates a new Chars instance by wrapping _string_.
def initialize(string)
diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb
index e0e0d9afc0..b0027047df 100644
--- a/activesupport/test/multibyte_chars_test.rb
+++ b/activesupport/test/multibyte_chars_test.rb
@@ -204,6 +204,12 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase
assert_equal 3, (@chars =~ /わ/u)
end
+ def test_match_should_return_boolean_for_regexp_match
+ assert_not @chars.match?(/wrong/u)
+ assert @chars.match?(/こに/u)
+ assert @chars.match?(/ち/u)
+ end
+
def test_should_use_character_offsets_for_insert_offsets
assert_equal "", (+"").mb_chars.insert(0, "")
assert_equal "こわにちわ", @chars.insert(1, "わ")