lib/lucid/ast/scenario_outline.rb in lucid-0.0.6 vs lib/lucid/ast/scenario_outline.rb in lucid-0.0.7
- old
+ new
@@ -9,16 +9,21 @@
include Names
include HasLocation
attr_accessor :feature
attr_reader :feature_tags
+ attr_reader :comment, :tags, :keyword
module ExamplesArray #:nodoc:
def accept(visitor)
return if Lucid.wants_to_quit
- each do |examples|
- visitor.visit_examples(examples)
+ return if self.empty?
+
+ visitor.visit_examples_array(self) do
+ each do |examples|
+ examples.accept(visitor)
+ end
end
end
end
# The +example_sections+ argument must be an Array where each element
@@ -30,17 +35,19 @@
def accept(visitor)
return if Lucid.wants_to_quit
raise_missing_examples_error unless @example_sections
- visitor.visit_comment(@comment) unless @comment.empty?
- visitor.visit_tags(@tags)
- visitor.visit_scenario_name(@keyword, name, file_colon_line, source_indent(first_line_length))
- visitor.visit_steps(steps)
+ visitor.visit_feature_element(self) do
+ comment.accept(visitor)
+ tags.accept(visitor)
+ visitor.visit_scenario_name(keyword, name, file_colon_line, source_indent(first_line_length))
+ steps.accept(visitor)
- skip_invoke! if @background.failed?
- visitor.visit_examples_array(examples_array) unless examples_array.empty?
+ skip_invoke! if @background.failed?
+ examples_array.accept(visitor)
+ end
end
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 = []
@@ -61,14 +68,10 @@
examples_array.each { |examples| examples.skip_invoke! }
end
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
+ @background.step_collection(step_invocations)
end
def each_example_row(&proc)
examples_array.each do |examples|
examples.each_example_row(&proc)