From ef4f54b3a9358fa1c378223306f0c59f259063e1 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 8 Apr 2020 15:33:59 +0100 Subject: [PATCH] Use shared class_exec fallback from rspec-support --- lib/rspec/core/shared_example_group.rb | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/lib/rspec/core/shared_example_group.rb b/lib/rspec/core/shared_example_group.rb index 6e21e6dfc6..3d9efce282 100644 --- a/lib/rspec/core/shared_example_group.rb +++ b/lib/rspec/core/shared_example_group.rb @@ -1,3 +1,5 @@ +RSpec::Support.require_rspec_support "with_keywords_when_needed" + module RSpec module Core # Represents some functionality that is shared with multiple example groups. @@ -33,31 +35,10 @@ def include_in(klass, inclusion_line, args, customization_block) klass.update_inherited_metadata(@metadata) unless @metadata.empty? SharedExampleGroupInclusionStackFrame.with_frame(@description, inclusion_line) do - klass_exec(klass, *args, &@definition) + RSpec::Support::WithKeywordsWhenNeeded.class_exec(klass, *args, &@definition) klass.class_exec(&customization_block) if customization_block end end - - private - - 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 - klass.class_exec(*args, **kwargs, &definition) - else - klass.class_exec(*args, &definition) - end - end - CODE - else - def klass_exec(klass, *args, &definition) - klass.class_exec(*args, &definition) - end - end end # Shared example groups let you define common context and/or common