Sha256: 143a81179b548a85f7da169af0e2bb5ee04547be16a05ee128f36b4cdb230d18

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

require 'cucumber/runtime/features_loader'

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
    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)
      tag_expression = Gherkin::TagExpression.new(tags)
      scenario_line_logger = JCukeForker::Formatters::ScenarioLineLogger.new(tag_expression)
      loader = Cucumber::Runtime::FeaturesLoader.new(feature_files, [], tag_expression)

      loader.features.each do |feature|
        feature.accept(scenario_line_logger)
      end

      scenario_line_logger.scenarios
    end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jcukeforker-0.3.1 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.10 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.9 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.8 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.7 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.6 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.5 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.4 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.3 lib/jcukeforker/scenarios.rb
jcukeforker-0.2.2 lib/jcukeforker/scenarios.rb