Drieam / rspec-github

Formatter for RSpec to show errors in GitHub action annotations
https://drieam.github.io/rspec-github/
MIT License
61 stars 10 forks source link

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

Closed madebydna closed 4 years ago

madebydna commented 4 years ago

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?

StefSchenkelaars commented 4 years ago

@madebydna Well, I'm doubting a bit if we should even fix this. Since ruby 2.4.x is even not supported anymore. But I'll add a testing matrix so we can at least get some insights.

And probably I'll fix this ;)

StefSchenkelaars commented 4 years ago

Released in https://github.com/Drieam/rspec-github/releases/tag/2.3.1

madebydna commented 4 years ago

Thank you @StefSchenkelaars! Unfortunately we're currently tied to ruby 2.4 so it's great that we can still use this gem 🙂