rspec / rspec-support

Common code needed by the other RSpec gems. Not intended for direct use.
https://rspec.info
MIT License
95 stars 103 forks source link

Allow string keys for method kwarg splats #591

Closed malcolmohare closed 5 months ago

malcolmohare commented 5 months ago

Attempting to fix: https://github.com/rspec/rspec-support/issues/554

The change expands the matching criteria for kwargs from x.is_a?(Symbol) to x.is_a?(Symbol) || x.is_a?(String). This now properly mirrors the behavior in the ruby docs.

https://docs.ruby-lang.org/en/3.0/syntax/calling_methods_rdoc.html#label-Hash+to+Keyword+Arguments+Conversion

Elsewhere tests were asserting that args with string keys were treated as optional arguments. I have not tested if this is true for ruby prior to ruby 3, but this is NOT true for ruby 3, and I've adjusted those tests.

Testing

bundle exec rspec spec/rspec/support/method_signature_verifier_spec.rb
...
Finished in 0.03491 seconds (files took 0.09141 seconds to load)
268 examples, 0 failures

Running script/run_build fails with a permissions error during rspec, so I don't have a clean test pass of the whole repo.

JonRowe commented 5 months ago

Thank you for this 👏

JonRowe commented 5 months ago

Released in 3.12.2 thank you!