Sha256: 4c00b53502b7c1b4aed6892fc17d34d4911ec3b2c783024c8acff11b9229e82d

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

require 'gherkin'
require 'pathname'

module CukeIterations
  class CukeParser
    class << self
      def parse_features(dir)
        scenarios = []
        Dir.glob(File.join(dir, '**/*.feature')).each do |feature_file|
          formatter = ScenarioExtractingFormatter.new
          parser = Gherkin::Parser::Parser.new (formatter)
          text = File.open(feature_file, 'r') { |f| f.read }
          parser.parse(text, __FILE__, __LINE__-1)

          scenarios << formatter.discovered_scenarios.each {|s| s[:filename] = relative_path(feature_file, dir)}
        end

        scenarios.flatten
      end

      private
      def relative_path(file, base_dir)
        Pathname.new(file).relative_path_from(Pathname.new(base_dir)).to_s
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cuke_iterations-0.0.2 lib/cuke_iterations/cuke_parser.rb