Module: RSpec::Support::WithKeywordsWhenNeeded

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/with_keywords_when_needed.rb

Instance Method Summary collapse

Instance Method Details

#class_exec(klass, *args, &block) ⇒ Object

Remove this in RSpec 4 in favour of explicitly passed in kwargs where this is used. Works around a warning in Ruby 2.7



15
16
17
18
19
20
21
22
23
24
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/with_keywords_when_needed.rb', line 15

def class_exec(klass, *args, &block)
  if MethodSignature.new(block).has_kw_args_in?(args)
    binding.eval(<<-CODE, __FILE__, __LINE__)
    kwargs = args.pop
    klass.class_exec(*args, **kwargs, &block)
    CODE
  else
    klass.class_exec(*args, &block)
  end
end