Class: Object

Inherits:
BasicObject
Includes:
InstanceExecHelper
Defined in:
lib/cucumber/core_ext/instance_exec.rb

Overview

:nodoc:

Defined Under Namespace

Modules: InstanceExecHelper

Instance Method Summary collapse

Instance Method Details

#cucumber_instance_exec(check_arity, pseudo_method, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cucumber/core_ext/instance_exec.rb', line 11

def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
  cucumber_run_with_backtrace_filtering(pseudo_method) do
    if check_arity && !cucumber_compatible_arity?(args, block)
      instance_exec do
        ari = cucumber_arity(block)
        ari = ari < 0 ? (ari.abs-1).to_s+"+" : ari
        s1 = ari == 1 ? "" : "s"
        s2 = args.length == 1 ? "" : "s"
        raise Cucumber::ArityMismatchError.new(
          "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
        )
      end
    else
      instance_exec(*Cucumber::StepMother.transform_arguments(args), &block)
    end
  end
end