diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/access.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 2 |
2 files changed, 1 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index d94e1bfca2..6018fd9641 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -59,7 +59,7 @@ class String # str.from(0).to(-1) # => "hello" # str.from(1).to(-2) # => "ell" def to(position) - self[0, position + 1] + self[0..position] end # Returns the first character. If a limit is supplied, returns a substring diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 196dd1bce6..d4f8ba8cdd 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -272,12 +272,10 @@ class StringAccessTest < ActiveSupport::TestCase end test "#to with negative Fixnum, position is counted from the end" do - skip "functionality was broken with 2ef1fb2c455ca53a0c1e1768f50824926ce28bd3" assert_equal "hell", "hello".to(-2) end test "#from and #to can be combined" do - skip "functionality was broken with 2ef1fb2c455ca53a0c1e1768f50824926ce28bd3" assert_equal "hello", "hello".from(0).to(-1) assert_equal "ell", "hello".from(1).to(-2) end |