Sha256: 877384617988385e0f95e808b764789ed872668901d8fe1f8187bfe6d6427bcc

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'cucumber/core'
require 'cucumber/core/filter'

module JCukeForker

  #
  # CukeForker::Scenarios.by_args(args)
  #
  # where 'args' is a String of cucumber options
  #
  # For example:
  # CukeForker::Scenarios.by_args(%W[-p my_profile -t @edition])
  # will return an array of scenarios and their line numbers that match
  # the tags specified in the cucumber profile 'my_profile' AND have the '@edition' tag
  #

  class Scenarios
    include Cucumber::Core
    def self.by_args(args)
      options = Cucumber::Cli::Options.new(STDOUT, STDERR, :default_profile => 'default')
      tagged(options.parse!(args)[:tag_expressions])
    end

    def self.all
      any_tag = []
      tagged any_tag
    end

    def self.tagged(tags)
      scenario_list = ScenarioList.new
      feature_files.each do |feature|
        source = JCukeForker::NormalisedEncodingFile.read(feature)
        file = Cucumber::Core::Gherkin::Document.new(feature, source)
        self.new.execute([file], scenario_list, [Cucumber::Core::Test::TagFilter.new(tags)])
      end
      scenario_list.scenarios
    end

    def self.feature_files
      Dir.glob('**/**.feature')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jcukeforker-0.4.0 lib/jcukeforker/scenarios.rb