Sha256: e64f72a0fb7e548a2c995f7157e5ea509e17c7473b6797b51e7e34dc261de11d

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

module Gurke
  #
  class Feature
    #
    # Return path to file containing this feature.
    #
    # @return [String] File path.
    #
    attr_reader :file

    # Return line number where this feature is defined.
    #
    # @return [Fixnum] Line number.
    #
    attr_reader :line

    # List of scenarios this feature specifies.
    #
    # @return [Array<Scenario>] Scenarios.
    #
    attr_reader :scenarios

    # List of backgrounds this feature specifies.
    #
    # @return [Array<Background>] Backgrounds.
    #
    attr_reader :backgrounds

    attr_reader :tags

    # @api private
    attr_reader :raw

    # @api private
    def initialize(file, line, tags, raw)
      @scenarios   = RunList.new
      @backgrounds = RunList.new

      @file = file
      @line = line
      @tags = tags
      @raw  = raw
    end

    def name
      raw.name
    end

    def description
      raw.description
    end

    # Return name of this feature.
    #
    # @return [String] Feature name.
    #
    def name
      raw.name
    end

    def failed?
      scenarios.any?(&:failed?)
    end

    def pending?
      scenarios.any?(&:pending?)
    end

    # @api private
    def run(runner, reporter)
      reporter.invoke :before_feature, self

      runner.hook :feature, nil do
        run_feature runner, reporter
      end
    ensure
      reporter.invoke :after_feature
    end

    private

    def run_feature(runner, reporter)
      reporter.invoke :start_feature, self

      scenarios.run runner, reporter
    ensure
      reporter.invoke :end_feature, self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gurke-2.0.0.dev.1.b20 lib/gurke/feature.rb
gurke-2.0.0.dev.1.b19 lib/gurke/feature.rb
gurke-2.0.0.dev.1.b18 lib/gurke/feature.rb