Use of String#delete_prefix creates dependency on ruby >= 2.5 · Issue #8 · Drieam/rspec-github · GitHub
Skip to content

Use of String#delete_prefix creates dependency on ruby >= 2.5 #8

Description

@madebydna

I just noticed that the RSpec::Github::NotificationDecorator class uses the #delete_prefix String method in its #path method:

def path
  File.realpath(raw_path).delete_prefix("#{workspace}#{File::SEPARATOR}")
end

I have Ruby 2.4.2 app and formatting a failing spec threw a NoMethodError:

Failure/Error: File.realpath(raw_path).delete_prefix("#{workspace}#{File::SEPARATOR}")

     NoMethodError:
       undefined method `delete_prefix' for #<String:0x00007fcf7abf4e50>

When I researched the problem I found that #delete_prefix is a String method introduced in Ruby 2.5. According to the gemspec, the min Ruby requirement is >= 2.3.0.

Perhaps we could replace the use of delete_prefix with a simple sub call, or else update the Ruby requirement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions