rspec / rspec-support

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

[bugfix] Properly detect kwargs hashes vs optional positional args #594

Open malcolmohare opened 7 months ago

malcolmohare commented 7 months ago

Attempting to fix https://github.com/rspec/rspec-expectations/issues/1451

Refactor has_kw_args_in?:

Added backwards compatible ruby2_keywords wrapping to the necessary methods (valid? and error_for) in the spec files like so: ruby2_keywords(:valid?) if respond_to?(:ruby2_keywords, true)

Also needed to modify how args are passed to the MSV split_args so that the special kwargs markings are not lost.

pirj commented 7 months ago

Fails on Ruby 3+

malcolmohare commented 7 months ago

Fully backwards compatible, just need to fix 3.2 and up. The behavior of ruby2_keywords changed between 3.1 and 3.2: https://rubyreferences.github.io/rubychanges/3.2.html#keyword-argument-separation-leftovers