fastruby / next_rails

A toolkit to upgrade your next Rails application
https://www.fastruby.io/blog/upgrade-rails/dual-boot/dual-boot-with-rails-6-0-beta.html?utm_source=github&utm_medium=description&utm_campaign=github&utm_term=next-rails
MIT License
466 stars 28 forks source link

[BUG] ERB fails to process template with `trim_mode: "-"` #99

Closed arielj closed 1 year ago

arielj commented 1 year ago

Expected Behavior

Generating the report should succeed with no error.

Actual Behavior

In some cases (maybe specific ERB versions and Ruby versions combination?), there's an error in this line:

https://github.com/fastruby/next_rails/blob/main/lib/next_rails/bundle_report.rb#L52

TypeError: no implicit conversion of Hash into Integer

ERB 2.1.0 does NOT support the trim_mode: keyword argument, it has a positional argument.

Possible Fix

Check which version of ERB is the project running (with ERB.version) and use different parameters.

To Reproduce

Use an old ERB version (has to be older than 2.2) Call ERB.new("some string", trim_mode: "-").result(binding) and it should fail with the error. Call ERB.new("some_string", nil, "-").result(binding) and it should work

Additional Information

Found this with ERB 2.1.0 and Ruby 2.3.8.

I will abide by the code of conduct