Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

`starts/ends_with?` implementations incompatible with that of ruby 1.8.7

#3199

starts/ends_with? methods shouldn't cast argument to string because ruby 1.8.7 doesn't seem to do that. for example:

"foobar".ends_with?(:bar)
# => true in ActiveSupport implementation, false in ruby 1.8.7

Reported by Mislav · September 14th, 2009 @ 02:57 PM

State: committed
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Mislav
    Mislav
    • Tag changed from 1.8.7, activesupport, string to 1.8.7, activesupport, patch, string

    September 14th, 2009 @ 03:01 PM

  2. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 1.8.7, activesupport, patch, string to 1.8.7, activesupport, bugmash, patch, string

    September 25th, 2009 @ 12:13 PM

  3. Dmitry Maksimov
    Dmitry Maksimov

    not reproducible
    Tried on Rails 2.3.4 and rails starts/ends_with? methods work such as ruby 1.8.7 start/end_with? methods. -1 the patch is ok, but there is no bug, so there is no need in patch?

    September 26th, 2009 @ 07:36 PM

  4. John Pignata
    John Pignata

    verified the difference in implementations

    +1 patch applies cleanly to master

    September 26th, 2009 @ 09:02 PM

  5. Blue Box Chris
    Blue Box Chris

    -1 Not reproducible

    "foobar".ends_with?('bar') => true "foobar".ends_with?(:bar) => true

    September 26th, 2009 @ 10:32 PM

  6. Matías Flores
    Matías Flores

    +1 patch applies cleanly to 2-3-stable but failed in master

    verified the difference in behavior Mislav was talking about

    Some additional info: when you're confirming this issue be sure to test it with 1.8.6, as in 1.8.7 and above starts_with and ends_with are just aliases of ruby's start_with and end_with.

    September 27th, 2009 @ 02:41 AM

  7. Elad Meidar
    Elad Meidar

    +1 verified the bug and the 2-3-stable patch applies cleanly, i've attached a patch for master, note that i didn't credit Mislav.. but only because i have no idea how to do it.

    September 27th, 2009 @ 03:41 AM

  8. sr.iniv.t
    sr.iniv.t

    In Ruby 1.8.6, there's no Symbol#length apparently (maybe I'm on an older patchlevel?):

    ts > ruby -v
    ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
    ts > irb
    irb(main):001:0> :str.length
    NoMethodError: undefined method `length' for :str:Symbol
        from (irb):1
    

    September 27th, 2009 @ 05:22 AM

  9. Mislav
    Mislav

    To those who claim they can't reproduce: my ruby version on Snow Leopard is

    ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
    

    So if you can find another 1.8.7 version where this is not false:

    "foobar".end_with(:bar)
    

    Then please report here. Otherwise, this patch is still valid.

    Elad: the way of properly crediting people with git commit is to either reference metadata from another commit (-c | -C options) or to use the --author option.

    October 11th, 2009 @ 10:32 AM

  10. Rizwan Reza
    Rizwan Reza
    • Tag changed from 1.8.7, activesupport, bugmash, patch, string to 1.8.7, activesupport, patch, string

    February 12th, 2010 @ 12:46 PM

  11. Mislav
    Mislav
    • Tag changed from 1.8.7, activesupport, patch, string to 1.8.7, 2.3.x, activesupport, patch, string

    Rebased the patch to 2-3-stable branch. Version of this patch for master isn't necessary because Rails 3.0 drops Ruby 1.8.6 support.

    April 16th, 2010 @ 02:13 PM

  12. Repository
    Repository
    • State changed from new to committed

    (from [c519215aa83b041d438772977f962f54fff81a83]) ruby 1.8.7 compat: starts/ends_with? doesn't cast to string

    starts/ends_with? methods shouldn't cast argument to string because ruby 1.8.7 doesn't seem to do that. for example:

    "foobar".ends_with?(:bar)
    # => true in ActiveSupport implementation, false in ruby 1.8.7
    

    [#3199 state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/c519215aa83b041d438772977f962f...

    April 16th, 2010 @ 07:23 PM