Class: TestRunner::TestList
- Inherits:
-
Object
- Object
- TestRunner::TestList
- Defined in:
- lib/test-runner/test_list.rb
Instance Method Summary collapse
-
#all ⇒ Array<Test>
Return a list of all known tests.
-
#by_path(path) ⇒ Test
Return one test specified by path.
- #create_test(path, data) ⇒ Object protected
- #extract_all ⇒ Object protected
- #extract_one(path) ⇒ Object protected
-
#filter {|| ... } ⇒ Array<Test>
Filter through all tests, return those that the filter matched.
-
#initialize(system: NixCli::DEFAULT_SYSTEM, test_config_path: nil) ⇒ TestList
constructor
A new instance of TestList.
- #parse_many(json) ⇒ Object protected
- #parse_one(path, json) ⇒ Object protected
Constructor Details
#initialize(system: NixCli::DEFAULT_SYSTEM, test_config_path: nil) ⇒ TestList
Returns a new instance of TestList.
5 6 7 |
# File 'lib/test-runner/test_list.rb', line 5 def initialize(system: NixCli::DEFAULT_SYSTEM, test_config_path: nil) @nix = NixCli.new(system:, test_config_path:) end |
Instance Method Details
#all ⇒ Array<Test>
Return a list of all known tests
11 12 13 |
# File 'lib/test-runner/test_list.rb', line 11 def all parse_many(extract_all) end |
#by_path(path) ⇒ Test
Return one test specified by path
24 25 26 |
# File 'lib/test-runner/test_list.rb', line 24 def by_path(path) parse_one(path, extract_one(path)) end |
#create_test(path, data) ⇒ Object (protected)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/test-runner/test_list.rb', line 48 def create_test(path, data) Test.new( path: path, type: data['type'], template: data['template'], template_args: data['templateArgs'], test_args: data.fetch('testArgs', {}), name: data['name'], description: data['description'], attempts: data['attempts'], expect_failure: data['expectFailure'], tags: data['tags'], labels: data['labels'], test_scripts: data['testScripts'] ) end |
#extract_all ⇒ Object (protected)
30 31 32 |
# File 'lib/test-runner/test_list.rb', line 30 def extract_all @nix. end |
#extract_one(path) ⇒ Object (protected)
34 35 36 |
# File 'lib/test-runner/test_list.rb', line 34 def extract_one(path) @nix.(path) end |
#filter {|| ... } ⇒ Array<Test>
Filter through all tests, return those that the filter matched
18 19 20 |
# File 'lib/test-runner/test_list.rb', line 18 def filter(&) all.select(&) end |
#parse_many(json) ⇒ Object (protected)
38 39 40 41 42 |
# File 'lib/test-runner/test_list.rb', line 38 def parse_many(json) JSON.parse(json).map do |name, opts| create_test(name, opts) end end |
#parse_one(path, json) ⇒ Object (protected)
44 45 46 |
# File 'lib/test-runner/test_list.rb', line 44 def parse_one(path, json) create_test(path, JSON.parse(json)) end |