class Cucumber::RbStepDefinition
end
# some code here
Given /I have (d+) cucumbers in my belly/ do
in the step_definitions
ruby files - for example:
by calling Given
, When
or Then
A Step Definition holds a Regexp and a Proc, and is created
def file
def file @file ||= file_colon_line.split(':')[0] end
def file_colon_line
def file_colon_line @proc.file_colon_line end
def initialize(rb_language, pattern, &proc)
def initialize(rb_language, pattern, &proc) raise MissingProc if proc.nil? if String === pattern p = pattern.gsub(/\$\w+/, '(.*)') # Replace $var with (.*) pattern = Regexp.new("^#{p}$") end @rb_language, @regexp, @proc = rb_language, pattern, proc end
def invoke(args)
def invoke(args) args = args.map{|arg| Ast::PyString === arg ? arg.to_s : arg} begin @rb_language.current_world.cucumber_instance_exec(true, regexp.inspect, *args, &@proc) rescue Cucumber::ArityMismatchError => e e.backtrace.unshift(self.backtrace_line) raise e end end
def regexp
def regexp @regexp end