Sha256: 3a3a6d99df0d29dc9678cefe6bdd140d494ed7e6855cb040ae4e65bbd10f54fe

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

require 'lucid/ast/names'

module Lucid
  module AST
    class Examples #:nodoc:
      include Names
      include HasLocation
      attr_writer :outline_table
      attr_reader :comment, :keyword, :outline_table

      def initialize(location, comment, keyword, title, description, outline_table)
        @location, @comment, @keyword, @title, @description, @outline_table = location, comment, keyword, title, description, outline_table
        raise ArgumentError unless @location.is_a?(Location)
        raise ArgumentError unless @comment.is_a?(Comment)
      end

      attr_reader :gherkin_statement
      def gherkin_statement(statement=nil)
        @gherkin_statement ||= statement
      end

      def accept(visitor)
        visitor.visit_examples(self) do
          comment.accept(visitor)
          visitor.visit_examples_name(keyword, name)
          outline_table.accept(visitor)
        end
      end

      def skip_invoke!
        @outline_table.skip_invoke!
      end

      def each_example_row(&proc)
        @outline_table.cells_rows[1..-1].each(&proc)
      end

      def failed?
        @outline_table.cells_rows[1..-1].select{|row| row.failed?}.any?
      end

      def to_sexp
        sexp = [:examples, @keyword, name]
        comment = comment.to_sexp
        sexp += [comment] if comment
        sexp += [@outline_table.to_sexp]
        sexp
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lucid-0.5.1 lib/lucid/ast/examples.rb
lucid-0.4.1 lib/lucid/ast/examples.rb
lucid-0.4.0 lib/lucid/ast/examples.rb
lucid-0.3.3 lib/lucid/ast/examples.rb
lucid-0.3.0 lib/lucid/ast/examples.rb
lucid-0.2.1 lib/lucid/ast/examples.rb
lucid-0.2.0 lib/lucid/ast/examples.rb
lucid-0.1.1 lib/lucid/ast/examples.rb
lucid-0.1.0 lib/lucid/ast/examples.rb