Class: Megatest::Selector::Loader
- Inherits:
-
Object
- Object
- Megatest::Selector::Loader
- Defined in:
- lib/megatest/selector.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #append_paths(paths_to_load) ⇒ Object
- #append_tests(tests_to_run, registry, random:) ⇒ Object
-
#initialize(config, path, filter = nil) ⇒ Loader
constructor
A new instance of Loader.
- #partial? ⇒ Boolean
- #select(registry) ⇒ Object
Constructor Details
#initialize(config, path, filter = nil) ⇒ Loader
Returns a new instance of Loader.
59 60 61 62 63 64 65 66 67 |
# File 'lib/megatest/selector.rb', line 59 def initialize(config, path, filter = nil) @config = config @path = File.(path) if @directory = File.directory?(@path) @path = File.join(@path, "/") end @paths = nil @filter = filter end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
57 58 59 |
# File 'lib/megatest/selector.rb', line 57 def path @path end |
Instance Method Details
#append_paths(paths_to_load) ⇒ Object
82 83 84 |
# File 'lib/megatest/selector.rb', line 82 def append_paths(paths_to_load) paths_to_load.concat(paths) end |
#append_tests(tests_to_run, registry, random:) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/megatest/selector.rb', line 73 def append_tests(tests_to_run, registry, random:) test_cases = select(registry) if partial? test_cases.sort! test_cases.shuffle!(random: random) if random end tests_to_run.concat(test_cases) end |
#partial? ⇒ Boolean
69 70 71 |
# File 'lib/megatest/selector.rb', line 69 def partial? !!@filter end |
#select(registry) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/megatest/selector.rb', line 86 def select(registry) test_cases = if @directory registry.test_cases.select do |test_case| test_case.source_file.start_with?(@path) end else registry.test_cases_by_path(@path) end if @filter @filter.select(test_cases) else test_cases end end |