Sha256: 49c39417b0690ce3c1f2c490d9941eaaa2c37e00a28dbc3418ceeae301ee21a1

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

module YARD::CodeObjects::Cucumber
  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, :tags, :scenario

      # 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

8 entries across 8 versions & 3 rubygems

Version Path
yard-gherkin-turnip-1.0.2 lib/yard/code_objects/cucumber/scenario_outline.rb
yard-gherkin-turnip-1.0.1 lib/yard/code_objects/cucumber/scenario_outline.rb
yard-gherkin-turnip-1.0.0 lib/yard/code_objects/cucumber/scenario_outline.rb
yard-nrser-cucumber-0.1.3 lib/yard/code_objects/cucumber/scenario_outline.rb
yard-nrser-cucumber-0.1.2 lib/yard/code_objects/cucumber/scenario_outline.rb
yard-nrser-cucumber-0.1.1 lib/yard/code_objects/cucumber/scenario_outline.rb
yard-nrser-cucumber-0.1.0 lib/yard/code_objects/cucumber/scenario_outline.rb
yard-cucumber-4.0.0 lib/yard/code_objects/cucumber/scenario_outline.rb