Class: Cucumber::Ast::ScenarioOutline
- Includes:
- FeatureElement
- Defined in:
- lib/cucumber/ast/scenario_outline.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ExamplesArray
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from FeatureElement
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #add_examples(example_section) ⇒ Object
- #each_example_row(&proc) ⇒ Object
- #fail!(exception) ⇒ Object
- #failed? ⇒ Boolean
- #init ⇒ Object
-
#initialize(background, comment, tags, line, keyword, name, raw_steps, example_sections) ⇒ ScenarioOutline
constructor
The
example_sections
argument must be an Array where each element is another array representing an Examples section. - #skip_invoke! ⇒ Object
- #step_invocations(cells) ⇒ Object
- #to_sexp ⇒ Object
- #visit_scenario_name(visitor, row) ⇒ Object
Methods included from FeatureElement
#accept_hook?, #add_step, #attach_steps, #backtrace_line, #file_colon_line, #first_line_length, #language, #matches_scenario_names?, #max_line_length, #name_line_lengths, #source_indent, #source_tag_names, #text_length
Constructor Details
#initialize(background, comment, tags, line, keyword, name, raw_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
23 24 25 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 23 def initialize(background, comment, , line, keyword, name, raw_steps, example_sections) @background, @comment, @tags, @line, @keyword, @name, @raw_steps, @example_sections = background, comment, , line, keyword, name, raw_steps, example_sections end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 6 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 52 def accept(visitor) return if Cucumber.wants_to_quit visitor.visit_comment(@comment) unless @comment.empty? visitor.(@tags) visitor.visit_scenario_name(@keyword, @name, file_colon_line(@line), source_indent(first_line_length)) visitor.visit_steps(@steps) skip_invoke! if @background && @background.failed? visitor.visit_examples_array(@examples_array) unless @examples_array.empty? end |
#add_examples(example_section) ⇒ Object
27 28 29 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 27 def add_examples(example_section) @example_sections << example_section end |
#each_example_row(&proc) ⇒ Object
84 85 86 87 88 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 84 def each_example_row(&proc) @examples_array.each do |examples| examples.each_example_row(&proc) end end |
#fail!(exception) ⇒ Object
63 64 65 66 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 63 def fail!(exception) # Just a hack for https://rspec.lighthouseapp.com/projects/16211/tickets/413-scenario-outlines-that-fail-with-exception-exit-process # Also see http://groups.google.com/group/cukes/browse_thread/thread/41cd567cb9df4bc3 end |
#failed? ⇒ Boolean
99 100 101 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 99 def failed? @examples_array.select{|examples| examples.failed?}.any? end |
#init ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 31 def init return if @steps attach_steps(@raw_steps) @steps = StepCollection.new(@raw_steps) @examples_array = @example_sections.map do |example_section| examples_comment = example_section[0] examples_line = example_section[1] examples_keyword = example_section[2] examples_name = example_section[3] examples_matrix = example_section[4] examples_table = OutlineTable.new(examples_matrix, self) Examples.new(examples_comment, examples_line, examples_keyword, examples_name, examples_table) end @examples_array.extend(ExamplesArray) @background.feature_elements << self if @background end |
#skip_invoke! ⇒ Object
68 69 70 71 72 73 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 68 def skip_invoke! @examples_array.each{|examples| examples.skip_invoke!} @feature.next_feature_element(self) do |next_one| next_one.skip_invoke! end end |
#step_invocations(cells) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 75 def step_invocations(cells) step_invocations = @steps.step_invocations_from_cells(cells) if @background @background.step_collection(step_invocations) else StepCollection.new(step_invocations) end end |
#to_sexp ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 103 def to_sexp init sexp = [:scenario_outline, @keyword, @name] comment = @comment.to_sexp sexp += [comment] if comment = @tags.to_sexp sexp += if .any? steps = @steps.to_sexp sexp += steps if steps.any? sexp += @examples_array.map{|e| e.to_sexp} sexp end |
#visit_scenario_name(visitor, row) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/cucumber/ast/scenario_outline.rb', line 90 def visit_scenario_name(visitor, row) visitor.visit_scenario_name( @feature.language.keywords('scenario')[0], row.name, file_colon_line(row.line), source_indent(first_line_length) ) end |