Class: Cucumber::Ast::ScenarioOutline
- Defined in:
- lib/cucumber/ast/scenario_outline.rb
Instance Attribute Summary
Attributes inherited from Scenario
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #at_lines?(lines) ⇒ Boolean
- #execute_row(cells, visitor, &proc) ⇒ Object
-
#initialize(comment, tags, line, keyword, name, steps, example_sections) ⇒ ScenarioOutline
constructor
The
example_sections
argument must be an Array where each element is another array representing an Examples section. - #pending? ⇒ Boolean
- #to_sexp ⇒ Object
Methods inherited from Scenario
#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(comment, , line, keyword, name, steps, example_sections) super(comment, , 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_comment(@comment) visitor.(@tags) visitor.visit_scenario_name(@keyword, @name, file_line(@line), source_indent(text_length)) @steps.each do |step| visitor.visit_step(step) end @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 |
#execute_row(cells, visitor, &proc) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 41 def execute_row(cells, visitor, &proc) exception = nil visitor.world(self) do |world| previous_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) # There might be steps that don't have any arguments # If there are no matched args, we'll still iterate once 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
68 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 68 def pending? ; false ; end |
#to_sexp ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 70 def to_sexp sexp = [:scenario_outline, @keyword, @name] comment = @comment.to_sexp sexp += [comment] if comment = @tags.to_sexp sexp += if .any? steps = @steps.map{|step| step.to_sexp} sexp += steps if steps.any? sexp += @examples_array.map{|e| e.to_sexp} sexp end |