Class: Smartest::CLIArguments
- Inherits:
-
Object
- Object
- Smartest::CLIArguments
- Defined in:
- lib/smartest/cli_arguments.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#line_filters ⇒ Object
readonly
Returns the value of attribute line_filters.
Instance Method Summary collapse
- #filter_tests? ⇒ Boolean
-
#initialize(argv) ⇒ CLIArguments
constructor
A new instance of CLIArguments.
- #select_tests(tests) ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLIArguments
Returns a new instance of CLIArguments.
9 10 11 12 13 14 15 |
# File 'lib/smartest/cli_arguments.rb', line 9 def initialize(argv) @files = [] @whole_files = Set.new @line_filters = Hash.new { |hash, key| hash[key] = Set.new } parse(argv.empty? ? ["smartest/**/*_test.rb"] : argv) end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/smartest/cli_arguments.rb', line 7 def files @files end |
#line_filters ⇒ Object (readonly)
Returns the value of attribute line_filters.
7 8 9 |
# File 'lib/smartest/cli_arguments.rb', line 7 def line_filters @line_filters end |
Instance Method Details
#filter_tests? ⇒ Boolean
17 18 19 |
# File 'lib/smartest/cli_arguments.rb', line 17 def filter_tests? @line_filters.any? end |
#select_tests(tests) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/smartest/cli_arguments.rb', line 21 def select_tests(tests) return tests unless filter_tests? tests.select do |test_case| next false unless test_case.location path = File.(test_case.location.path) @whole_files.include?(path) || @line_filters.fetch(path, []).any? { |line_filter| test_case.includes_line_range?(line_filter) } end end |