Sha256: dcf27b5dafc9a3c83f19cceabbce9f801f4cc71e8448751f3989174947f31793

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

require 'lucid/ast/names'

module Lucid
  module AST
    class Examples #:nodoc:
      include Names
      include HasLocation
      attr_writer :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)
        return if Lucid.wants_to_quit
        visitor.visit_comment(@comment) unless @comment.empty?
        visitor.visit_examples_name(@keyword, name)
        visitor.visit_outline_table(@outline_table)
      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

2 entries across 2 versions & 1 rubygems

Version Path
lucid-0.0.6 lib/lucid/ast/examples.rb
lucid-0.0.5 lib/lucid/ast/examples.rb