1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Merge pull request #39152 from kamipo/deprecate_starts_ends_with"

This reverts commit 55e038cf17, reversing
changes made to 8b900a7105.
This commit is contained in:
Ryuta Kamizono 2020-05-05 23:08:56 +09:00
parent 55e038cf17
commit 783a195cb7
4 changed files with 20 additions and 16 deletions

View file

@ -1,8 +1,3 @@
* Deprecate `starts_with?` and `ends_with?` for String core extensions.
Use the native `start_with?` and `end_with?` instead.
*Ryuta Kamizono*
* Add override of unary plus for `ActiveSupport::Duration`.
`+ 1.second` is now identical to `+1.second` to prevent errors

View file

@ -1,8 +1,6 @@
# frozen_string_literal: true
class String
alias_method :starts_with?, :start_with?
alias_method :ends_with?, :end_with?
deprecate starts_with?: :start_with?
deprecate ends_with?: :end_with?
alias :starts_with? :start_with?
alias :ends_with? :end_with?
end

View file

@ -239,15 +239,15 @@ class StringInflectionsTest < ActiveSupport::TestCase
assert_equal 97, "abc".ord
end
def test_deprecated_starts_ends_with_alias
def test_starts_ends_with_alias
s = "hello"
assert_deprecated { assert s.starts_with?("h") }
assert_deprecated { assert s.starts_with?("hel") }
assert_deprecated { assert_not s.starts_with?("el") }
assert s.starts_with?("h")
assert s.starts_with?("hel")
assert_not s.starts_with?("el")
assert_deprecated { assert s.ends_with?("o") }
assert_deprecated { assert s.ends_with?("lo") }
assert_deprecated { assert_not s.ends_with?("el") }
assert s.ends_with?("o")
assert s.ends_with?("lo")
assert_not s.ends_with?("el")
end
def test_string_squish

View file

@ -1212,6 +1212,17 @@ The `inquiry` method converts a string into a `StringInquirer` object making equ
NOTE: Defined in `active_support/core_ext/string/inquiry.rb`.
### `starts_with?` and `ends_with?`
Active Support defines 3rd person aliases of `String#start_with?` and `String#end_with?`:
```ruby
"foo".starts_with?("f") # => true
"foo".ends_with?("o") # => true
```
NOTE: Defined in `active_support/core_ext/string/starts_ends_with.rb`.
### `strip_heredoc`
The method `strip_heredoc` strips indentation in heredocs.