Skip to content

Commit

Permalink
Make the kwargs definition eval'd for older Rubies, can easily be rem…
Browse files Browse the repository at this point in the history
…oved in RSpec 4
  • Loading branch information
JonRowe committed Apr 4, 2020
1 parent cde847f commit 8cac9c3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rspec/core/shared_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def include_in(klass, inclusion_line, args, customization_block)
if RSpec::Support::RubyFeatures.kw_args_supported?
# Remove this in RSpec 4 in favour of explictly passed in kwargs down the entire
# stack, e.g. rspec/rspec-core#2711
binding.eval(<<-CODE, __FILE__, __LINE__)
def klass_exec(klass, *args, &definition)
if RSpec::Support::MethodSignature.new(definition).has_kw_args_in?(args)
kwargs = args.pop
Expand All @@ -51,6 +52,7 @@ def klass_exec(klass, *args, &definition)
klass.class_exec(*args, &definition)
end
end
CODE
else
def klass_exec(klass, *args, &definition)
klass.class_exec(*args, &definition)
Expand Down

0 comments on commit 8cac9c3

Please sign in to comment.