Sha256: d20715d3646f0dcb1b0d7a46271fe8b1587520d477d042b73f3dc544b0105cf6

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

module Cucumber
  module Ast
    class OutlineTable < Table
      def initialize(raw, scenario_outline)
        super(raw)
        @scenario_outline = scenario_outline
        @cells_class = ExampleCells
        create_step_invocations_for_example_rows!(scenario_outline)
      end

      def accept(visitor)
        cells_rows.each_with_index do |row, n|
          visitor.visit_table_row(row)
        end
        nil
      end

      def skip_invoke!
        example_rows.each do |cells|
          cells.skip_invoke!
        end
      end

      def create_step_invocations_for_example_rows!(scenario_outline)
        example_rows.each do |cells|
          cells.create_step_invocations!(scenario_outline)
        end
      end
      
      def example_rows
        cells_rows[1..-1]
      end

      class ExampleCells < Cells
        def create_step_invocations!(scenario_outline)
          @step_invocations = scenario_outline.step_invocations(self)
        end
        
        def skip_invoke!
          @step_invocations.each do |step_invocation|
            step_invocation.skip_invoke!
          end
        end

        def accept(visitor)
          if header?
            @cells.each do |cell|
              cell.status = :skipped_param
              visitor.visit_table_cell(cell)
            end
          else
            visitor.step_mother.before_and_after(self) do
              @step_invocations.each do |step_invocation|
                step_invocation.invoke(visitor.step_mother, visitor.options)
                @exception ||= step_invocation.exception
              end

              @cells.each do |cell|
                visitor.visit_table_cell(cell)
              end
            end
          end
        end

        private

        def header?
          index == 0
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
aslakhellesoy-cucumber-0.2.3.4 lib/cucumber/ast/outline_table.rb
cavalle-cucumber-0.2.3.3.1 lib/cucumber/ast/outline_table.rb
cavalle-cucumber-0.2.3.3.2 lib/cucumber/ast/outline_table.rb
kosmas58-cucumber-0.2.3.3 lib/cucumber/ast/outline_table.rb