Sha256: 5f4187b6065560a820efbe665c363625185089418a7033a72878b15c2d345acd

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

module YARD::CodeObjects::Lucid
  class ScenarioOutline < NamespaceObject
    attr_accessor :value, :comments, :keyword, :description, :steps, :tags, :feature
    attr_accessor :scenarios, :examples

    def initialize(namespace,name)
      super(namespace,name.to_s.strip)
      @comments = @description = @value = @feature = nil
      @steps = []
      @tags = []
      @scenarios = []
      @examples = []
    end

    def background?
      false
    end

    def outline?
      true
    end

    def examples?
      @examples.find { |example| example.rows }
    end

    class Examples
      attr_accessor :name, :line, :keyword, :comments, :rows

      # The first row of the rows contains the headers for the table
      def headers
        rows.first
      end

      # The data of the table starts at the second row. When there is no data then
      # return a empty string.
      def data
        rows ? rows[1..-1] : ""
      end

      def values_for_row(row)
        hash = {}

        headers.each_with_index do |header,index|
          hash[header] = data[row][index]
        end

        hash
      end

      def to_hash
        hash = {}

        rows.each_with_index do |header,index|
          hash[header] = rows.collect { |row| row[index] }
        end

        hash
      end

      def initialize(parameters = {})
        parameters.each { |key,value| send("#{key.to_sym}=",value) if respond_to? "#{key.to_sym}=" }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yard-lucid-0.5.0 lib/yard/code_objects/lucid/scenario_outline.rb
yard-lucid-0.4.0 lib/yard/code_objects/lucid/scenario_outline.rb
yard-lucid-0.3.0 lib/yard/code_objects/lucid/scenario_outline.rb
yard-lucid-0.2.0 lib/yard/code_objects/lucid/scenario_outline.rb
yard-lucid-0.1.0 lib/yard/code_objects/lucid/scenario_outline.rb