Sha256: b20aedcdb887e0b533ba1d07b991c0607165cc46de935ba6eb9d844d0a5b87cb

Contents?: true

Size: 1.55 KB

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
gurke-2.0.0.dev.1.b25 lib/gurke/feature.rb
gurke-2.0.0.dev.1.b24 lib/gurke/feature.rb
gurke-2.0.0.dev.1.b23 lib/gurke/feature.rb
gurke-2.0.0.dev.1.b22 lib/gurke/feature.rb