Module: Cucumber::StepDefinitionMethods

Included in:
StepDefinition
Defined in:
lib/cucumber/step_definition.rb

Instance Method Summary collapse

Instance Method Details

#backtrace_lineObject



41
42
43
# File 'lib/cucumber/step_definition.rb', line 41

def backtrace_line
  "#{file_colon_line}:in `#{regexp.inspect}'"
end

#format_args(step_name, format) ⇒ Object

Formats the matched arguments of the associated Step. This method is usually called from visitors, which render output.

The format can either be a String or a Proc.

If it is a String it should be a format string according to Kernel#sprinf, for example:

'<span class="param">%s</span></tt>'

If it is a Proc, it should take one argument and return the formatted argument, for example:

lambda { |param| "[#{param}]" }


30
31
32
# File 'lib/cucumber/step_definition.rb', line 30

def format_args(step_name, format)
  step_name.gzub(regexp, format)
end

#match(step_name) ⇒ Object



34
35
36
37
38
39
# File 'lib/cucumber/step_definition.rb', line 34

def match(step_name)
  case step_name
  when String then regexp.match(step_name)
  when Regexp then regexp == step_name
  end
end

#step_match(name_to_match, name_to_report) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/cucumber/step_definition.rb', line 7

def step_match(name_to_match, name_to_report)
  if(match = name_to_match.match(regexp))
    StepMatch.new(self, name_to_match, name_to_report, match.captures)
  else
    nil
  end
end

#text_lengthObject



45
46
47
# File 'lib/cucumber/step_definition.rb', line 45

def text_length
  regexp.inspect.jlength
end