Class: Cucumber::Ast::Step
Overview
Constant Summary
collapse
- INDENT =
2
Instance Attribute Summary collapse
Instance Method Summary
collapse
#file, #file_colon_line, #line, #location
Constructor Details
#initialize(language, location, keyword, name, multiline_arg = nil) ⇒ Step
16
17
18
19
|
# File 'lib/cucumber/ast/step.rb', line 16
def initialize(language, location, keyword, name, multiline_arg=nil)
@language, @location, @keyword, @name, @multiline_arg = language, location, keyword, name, multiline_arg
@language || raise("Language is required!")
end
|
Instance Attribute Details
#exception ⇒ Object
Returns the value of attribute exception.
12
13
14
|
# File 'lib/cucumber/ast/step.rb', line 12
def exception
@exception
end
|
#feature_element ⇒ Object
Returns the value of attribute feature_element.
12
13
14
|
# File 'lib/cucumber/ast/step.rb', line 12
def feature_element
@feature_element
end
|
#gherkin_statement(statement = nil) ⇒ Object
Returns the value of attribute gherkin_statement.
21
22
23
|
# File 'lib/cucumber/ast/step.rb', line 21
def gherkin_statement
@gherkin_statement
end
|
Returns the value of attribute keyword.
10
11
12
|
# File 'lib/cucumber/ast/step.rb', line 10
def keyword
@keyword
end
|
Returns the value of attribute language.
10
11
12
|
# File 'lib/cucumber/ast/step.rb', line 10
def language
@language
end
|
#multiline_arg ⇒ Object
Returns the value of attribute multiline_arg.
12
13
14
|
# File 'lib/cucumber/ast/step.rb', line 12
def multiline_arg
@multiline_arg
end
|
Returns the value of attribute name.
10
11
12
|
# File 'lib/cucumber/ast/step.rb', line 10
def name
@name
end
|
#options=(value) ⇒ Object
Sets the attribute options
11
12
13
|
# File 'lib/cucumber/ast/step.rb', line 11
def options=(value)
@options = value
end
|
#step_collection=(value) ⇒ Object
Sets the attribute step_collection
11
12
13
|
# File 'lib/cucumber/ast/step.rb', line 11
def step_collection=(value)
@step_collection = value
end
|
Instance Method Details
#accept(visitor) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/cucumber/ast/step.rb', line 49
def accept(visitor)
return if Cucumber.wants_to_quit
visit_step_result(visitor, first_match(visitor), @multiline_arg, :skipped, nil, nil)
end
|
#background? ⇒ Boolean
26
27
28
|
# File 'lib/cucumber/ast/step.rb', line 26
def background?
false
end
|
#backtrace_line ⇒ Object
84
85
86
|
# File 'lib/cucumber/ast/step.rb', line 84
def backtrace_line
@backtrace_line ||= feature_element.backtrace_line("#{keyword}#{name}", line) unless feature_element.nil?
end
|
88
89
90
|
# File 'lib/cucumber/ast/step.rb', line 88
def dom_id
@dom_id ||= file_colon_line.gsub(/\//, '_').gsub(/\./, '_').gsub(/:/, '_')
end
|
#first_match(visitor) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/cucumber/ast/step.rb', line 60
def first_match(visitor)
feature_element.each_example_row do |cells|
argument_hash = cells.to_hash
delimited_arguments = delimit_argument_names(argument_hash)
name_to_match = replace_name_arguments(delimited_arguments)
step_match = visitor.runtime.step_match(name_to_match, name) rescue nil
return step_match if step_match
end
NoStepMatch.new(self, name)
end
|
#source_indent ⇒ Object
76
77
78
|
# File 'lib/cucumber/ast/step.rb', line 76
def source_indent
feature_element.source_indent(text_length)
end
|
30
31
32
33
|
# File 'lib/cucumber/ast/step.rb', line 30
def status
:skipped
end
|
#step_invocation ⇒ Object
35
36
37
|
# File 'lib/cucumber/ast/step.rb', line 35
def step_invocation
StepInvocation.new(self, name, @multiline_arg, [])
end
|
#step_invocation_from_cells(cells) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/cucumber/ast/step.rb', line 39
def step_invocation_from_cells(cells)
matched_cells = matched_cells(cells)
delimited_arguments = delimit_argument_names(cells.to_hash)
name = replace_name_arguments(delimited_arguments)
multiline_arg = @multiline_arg.nil? ? nil : @multiline_arg.arguments_replaced(delimited_arguments)
StepInvocation.new(self, name, multiline_arg, matched_cells)
end
|
#text_length(name = name) ⇒ Object
80
81
82
|
# File 'lib/cucumber/ast/step.rb', line 80
def text_length(name=name)
INDENT + INDENT + keyword.unpack('U*').length + name.unpack('U*').length
end
|
72
73
74
|
# File 'lib/cucumber/ast/step.rb', line 72
def to_sexp
[:step, line, keyword, name, (@multiline_arg.nil? ? nil : @multiline_arg.to_sexp)].compact
end
|
#visit_step_result(visitor, step_match, multiline_arg, status, exception, background) ⇒ Object
56
57
58
|
# File 'lib/cucumber/ast/step.rb', line 56
def visit_step_result(visitor, step_match, multiline_arg, status, exception, background)
visitor.visit_step_result(keyword, step_match, @multiline_arg, status, exception, source_indent, background, file_colon_line)
end
|