You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

file_specs.rb 958 B

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. require 'cucumber'
  3. require 'cucumber/core/test/location'
  4. module Cucumber
  5. class FileSpecs
  6. FILE_COLON_LINE_PATTERN = /^([\w\W]*?)(?::([\d:]+))?$/ # :nodoc:
  7. def initialize(file_specs)
  8. Cucumber.logger.debug("Features:\n")
  9. @file_specs = file_specs.map { |spec| FileSpec.new(spec) }
  10. Cucumber.logger.debug("\n")
  11. end
  12. def locations
  13. @file_specs.map(&:locations).flatten
  14. end
  15. def files
  16. @file_specs.map(&:file).uniq
  17. end
  18. class FileSpec
  19. def initialize(spec)
  20. @file, @lines = *FILE_COLON_LINE_PATTERN.match(spec).captures
  21. Cucumber.logger.debug(" * #{@file}\n")
  22. @lines = String(@lines).split(':').map { |line| Integer(line) }
  23. end
  24. attr_reader :file
  25. def locations
  26. return [Core::Test::Location.new(@file)] if @lines.empty?
  27. @lines.map { |line| Core::Test::Location.new(@file, line) }
  28. end
  29. end
  30. end
  31. end

No Description

Contributors (1)