From ec0d55bb17c5991291e2ffb3e04536e77fd6e4c7 Mon Sep 17 00:00:00 2001 From: Elad Meidar Date: Sat, 26 Sep 2009 22:37:07 -0400 Subject: [PATCH] LH3199 - ported mislav's patch to Master, ends/starts with is now consistant between 1.8.7 and activesupport --- .../core_ext/string/starts_ends_with.rb | 2 -- activesupport/test/core_ext/string_ext_test.rb | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb index f65bb8f..7ebae28 100644 --- a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +++ b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb @@ -2,13 +2,11 @@ class String unless '1.8.7 and up'.respond_to?(:start_with?) # Does the string start with the specified +prefix+? def start_with?(prefix) - prefix = prefix.to_s self[0, prefix.length] == prefix end # Does the string end with the specified +suffix+? def end_with?(suffix) - suffix = suffix.to_s self[-suffix.length, suffix.length] == suffix end end diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index db9073e..35ef9d3 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -183,6 +183,7 @@ class StringInflectionsTest < Test::Unit::TestCase s = "hello" assert s.starts_with?('h') assert s.starts_with?('hel') + assert !(s.starts_with?(:hel)) assert !s.starts_with?('el') assert s.start_with?('h') @@ -195,6 +196,7 @@ class StringInflectionsTest < Test::Unit::TestCase assert s.end_with?('o') assert s.end_with?('lo') + assert !(s.end_with?(:lo)) assert !s.end_with?('el') end -- 1.6.0.2