rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.12k stars 553 forks source link

Support `Thor::CoreExt::HashWithIndifferentAccess#except` for Rails 6.0 #734

Closed koic closed 3 years ago

koic commented 4 years ago

This PR supports Thor::CoreExt::HashWithIndifferentAccess#except and prevents breaking changes in Rails upgrades when using options.except(:key) in Thor task.

When Thor is used with Rails (Active Support), the behavior changes as follows.

With Rails 5.2 or lower

h = Thor::CoreExt::HashWithIndifferentAccess.new(foo: 1, bar: 2)
h.except(:foo) #=> {"bar"=>2}

With Rails 6.0

h = Thor::CoreExt::HashWithIndifferentAccess.new(foo: 1, bar: 2)
h.except(:foo) #=> {"foo"=>1, "bar"=>2}

This difference behavior is due to the following changes in Rails 6.0. https://github.com/rails/rails/pull/35771

This PR makes the behavior between Rails 5.2 and Rails 6.0 compatible.