Sha256: 6415cd1fd4b28fd5660062fadbd235e741bed68959bbecd056d4f7e693cb19ae

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

module Cucumber
  module Tree
    class Feature
      attr_accessor :file
      
      def initialize(header, &proc)
        @header = header
        @scenarios = []
        instance_eval(&proc) if block_given?
      end

      def add_scenario(name, &proc)
        scenario = Scenario.new(self, name, &proc)
        @scenarios << scenario
        scenario
      end
      
      def add_row_scenario(template_scenario, values, line)
        scenario = RowScenario.new(self, template_scenario, values, line)
        @scenarios << scenario
        scenario
      end

      def Scenario(name, &proc)
        add_scenario(name, &proc)
      end
      
      def Table(matrix = [], &proc)
        table = Table.new(matrix)
        proc.call(table)
        template_scenario = @scenarios.last
        matrix[1..-1].each do |row|
          @scenarios << RowScenario.new(self, template_scenario, row, row.line)
        end
      end

      def accept(visitor)
        visitor.visit_header(@header)
        @scenarios.each do |scenario|
          visitor.visit_scenario(scenario)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aslakhellesoy-cucumber-0.1.1 lib/cucumber/tree/feature.rb
aslakhellesoy-cucumber-0.1.2 lib/cucumber/tree/feature.rb
aslakhellesoy-cucumber-0.1.3 lib/cucumber/tree/feature.rb
aslakhellesoy-cucumber-0.1.4 lib/cucumber/tree/feature.rb