Class: Cucumber::Ast::ScenarioOutline
Instance Attribute Summary
Attributes inherited from Scenario
#background, #feature
Instance Method Summary
collapse
Methods inherited from Scenario
#accept_steps, #at_header_or_step_lines?, #backtrace_line, #file_line, #matches_scenario_names?, #max_line_length, #previous_step, #source_indent, #status, #step_executed, #tagged_with?, #text_length, #undefined?
Constructor Details
#initialize(comment, tags, line, keyword, name, steps, example_sections) ⇒ ScenarioOutline
The example_sections
argument must be an Array where each element is another array representing an Examples section. This array has 3 elements:
-
Examples keyword
-
Examples section name
-
Raw matrix
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/cucumber/ast/scenario_outline.rb', line 10
def initialize(, tags, line, keyword, name, steps, example_sections)
super(, tags, line, keyword, name, steps)
steps.each {|step| step.status = :outline}
@examples_array = example_sections.map do |example_section|
examples_line = example_section[0]
examples_keyword = example_section[1]
examples_name = example_section[2]
examples_matrix = example_section[3]
examples_table = OutlineTable.new(examples_matrix, self)
Examples.new(examples_line, examples_keyword, examples_name, examples_table)
end
end
|
Instance Method Details
#accept(visitor) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/cucumber/ast/scenario_outline.rb', line 29
def accept(visitor)
visitor.visit_background(@background) if @background
visitor.(@comment)
visitor.visit_tags(@tags)
visitor.visit_scenario_name(@keyword, @name, file_line(@line), source_indent(text_length))
visitor.visit_steps(@steps_helper)
@examples_array.each do |examples|
visitor.visit_examples(examples)
end
end
|
#at_lines?(lines) ⇒ Boolean
25
26
27
|
# File 'lib/cucumber/ast/scenario_outline.rb', line 25
def at_lines?(lines)
super || @examples_array.detect { |examples| examples.at_lines?(lines) }
end
|
#each_example_row(&proc) ⇒ Object
41
42
43
44
45
|
# File 'lib/cucumber/ast/scenario_outline.rb', line 41
def each_example_row(&proc)
@examples_array.each do |examples|
examples.each_example_row(&proc)
end
end
|
#execute_row(cells, visitor, &proc) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/cucumber/ast/scenario_outline.rb', line 47
def execute_row(cells, visitor, &proc)
exception = nil
prior_world = @background ? @background.world : nil
visitor.world(self, prior_world) do |world|
previous_status = @background ? @background.status : :passed
argument_hash = cells.to_hash
cell_index = 0
@steps.each do |step|
executed_step, previous_status, matched_args =
step.execute_with_arguments(argument_hash, world, previous_status, visitor, cells[0].line)
matched_args = [nil] if matched_args.empty?
matched_args.each do
cell = cells[cell_index]
if cell
proc.call(cell, previous_status)
cell_index += 1
end
end
exception ||= executed_step.exception
end
end
@feature.scenario_executed(self) if @feature
exception
end
|
#pending? ⇒ Boolean
77
|
# File 'lib/cucumber/ast/scenario_outline.rb', line 77
def pending? ; false ; end
|
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/cucumber/ast/scenario_outline.rb', line 79
def to_sexp
sexp = [:scenario_outline, @keyword, @name]
= @comment.to_sexp
sexp += [] if
tags = @tags.to_sexp
sexp += tags if tags.any?
steps = @steps.map{|step| step.to_sexp}
sexp += steps if steps.any?
sexp += @examples_array.map{|e| e.to_sexp}
sexp
end
|