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.
61 62 63 64 65 66 67 68 69 |
# File 'lib/megatest/selector.rb', line 61 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.
59 60 61 |
# File 'lib/megatest/selector.rb', line 59 def path @path end |
Instance Method Details
#append_paths(paths_to_load) ⇒ Object
84 85 86 |
# File 'lib/megatest/selector.rb', line 84 def append_paths(paths_to_load) paths_to_load.concat(paths) end |
#append_tests(tests_to_run, registry, random:) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/megatest/selector.rb', line 75 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
71 72 73 |
# File 'lib/megatest/selector.rb', line 71 def partial? !!@filter end |
#select(registry) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/megatest/selector.rb', line 88 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 |