Class: Lucid::AST::ScenarioOutline
- Includes:
- HasLocation, HasSteps, Names
- Defined in:
- lib/lucid/ast/scenario_outline.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ExamplesArray
Instance Attribute Summary collapse
-
#background ⇒ Object
readonly
Returns the value of attribute background.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#feature ⇒ Object
Returns the value of attribute feature.
-
#feature_tags ⇒ Object
readonly
Returns the value of attribute feature_tags.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Attributes included from Names
Attributes included from HasSteps
#description, #gherkin_statement, #raw_steps, #title
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #each_example_row(&proc) ⇒ Object
- #fail!(exception) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(language, location, background, comment, tags, feature_tags, keyword, title, description, raw_steps, example_sections) ⇒ ScenarioOutline
constructor
The
example_sections
argument must be an Array where each element of the arry is another array representing an Examples section. - #skip_invoke! ⇒ Object
- #step_invocations(cells) ⇒ Object
- #to_sexp ⇒ Object
- #to_units(background) ⇒ Object
- #visit_scenario_name(visitor, row) ⇒ Object
Methods included from HasLocation
#file, #file_colon_line, #location
Methods included from Names
Methods included from HasSteps
#accept_hook?, #attach_steps, #backtrace_line, #first_line_length, #language, #matches_scenario_names?, #max_line_length, #name_line_lengths, #source_indent, #source_tag_names, #source_tags, #text_length
Constructor Details
#initialize(language, location, background, comment, tags, feature_tags, keyword, title, description, raw_steps, example_sections) ⇒ ScenarioOutline
The example_sections
argument must be an Array where each element of the arry is another array representing an Examples section.
30 31 32 33 |
# File 'lib/lucid/ast/scenario_outline.rb', line 30 def initialize(language, location, background, comment, , , keyword, title, description, raw_steps, example_sections) @language, @location, @background, @comment, @tags, @feature_tags, @keyword, @title, @description, @raw_steps, @example_sections = language, location, background, comment, , , keyword, title, description, raw_steps, example_sections attach_steps(@raw_steps) end |
Instance Attribute Details
#background ⇒ Object (readonly)
Returns the value of attribute background.
14 15 16 |
# File 'lib/lucid/ast/scenario_outline.rb', line 14 def background @background end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
14 15 16 |
# File 'lib/lucid/ast/scenario_outline.rb', line 14 def comment @comment end |
#feature ⇒ Object
Returns the value of attribute feature.
12 13 14 |
# File 'lib/lucid/ast/scenario_outline.rb', line 12 def feature @feature end |
#feature_tags ⇒ Object (readonly)
Returns the value of attribute feature_tags.
13 14 15 |
# File 'lib/lucid/ast/scenario_outline.rb', line 13 def @feature_tags end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
14 15 16 |
# File 'lib/lucid/ast/scenario_outline.rb', line 14 def keyword @keyword end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
14 15 16 |
# File 'lib/lucid/ast/scenario_outline.rb', line 14 def @tags end |
Instance Method Details
#accept(visitor) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/lucid/ast/scenario_outline.rb', line 35 def accept(visitor) background.accept(visitor) raise_missing_examples_error unless @example_sections visitor.visit_feature_element(self) do comment.accept(visitor) .accept(visitor) visitor.visit_scenario_name(keyword, name, file_colon_line, source_indent(first_line_length)) steps.accept(visitor) skip_invoke! if @background.failed? examples_array.accept(visitor) end end |
#each_example_row(&proc) ⇒ Object
75 76 77 78 79 |
# File 'lib/lucid/ast/scenario_outline.rb', line 75 def each_example_row(&proc) examples_array.each do |examples| examples.each_example_row(&proc) end end |
#fail!(exception) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/lucid/ast/scenario_outline.rb', line 59 def fail!(exception) # TODO: This is weak and is in fact just a hack. # This simply makes sure that a scenario outline that encounters # an exception just fails rather than causing a runtime error # and stack trace. end |
#failed? ⇒ Boolean
90 91 92 |
# File 'lib/lucid/ast/scenario_outline.rb', line 90 def failed? examples_array.select { |examples| examples.failed? }.any? end |
#skip_invoke! ⇒ Object
66 67 68 |
# File 'lib/lucid/ast/scenario_outline.rb', line 66 def skip_invoke! examples_array.each { |examples| examples.skip_invoke! } end |
#step_invocations(cells) ⇒ Object
70 71 72 73 |
# File 'lib/lucid/ast/scenario_outline.rb', line 70 def step_invocations(cells) step_invocations = steps.step_invocations_from_cells(cells) @background.create_step_invocations(step_invocations) end |
#to_sexp ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/lucid/ast/scenario_outline.rb', line 94 def to_sexp sexp = [:scenario_outline, @keyword, name] comment = @comment.to_sexp sexp += [comment] if comment = @tags.to_sexp sexp += if .any? sexp += steps.to_sexp if steps.any? sexp += examples_array.map{|e| e.to_sexp} sexp end |
#to_units(background) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/lucid/ast/scenario_outline.rb', line 50 def to_units(background) raise ArgumentError.new("#{background} != #{@background}") unless background == @background # maybe we don't need this argument, but it seems like the leaf AST nodes would be better not being aware of their parents. However step_invocations uses the ivar at the moment, so we'll just do this check to make sure its OK. result = [] each_example_row do |row| result << Unit.new(step_invocations(row)) end result end |
#visit_scenario_name(visitor, row) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/lucid/ast/scenario_outline.rb', line 81 def visit_scenario_name(visitor, row) visitor.visit_scenario_name( language.keywords('scenario')[0], row.name, Location.new(file, row.line).to_s, source_indent(first_line_length) ) end |