Class: Modsvaskr::TestsSuite
- Inherits:
-
Object
- Object
- Modsvaskr::TestsSuite
- Defined in:
- lib/modsvaskr/tests_suite.rb
Overview
Common functionality for any tests suite
Direct Known Subclasses
Modsvaskr::TestsSuites::ExteriorCell, Modsvaskr::TestsSuites::InteriorCell, Modsvaskr::TestsSuites::Npc
Instance Method Summary collapse
-
#clear_tests ⇒ Object
Remove all tests from this suite.
-
#initialize(tests_suite, game) ⇒ TestsSuite
constructor
Constructor.
-
#statuses ⇒ Object
Get test statuses.
-
#statuses=(statuses) ⇒ Object
Set test statuses.
Methods included from Logger
#log, #out, #wait_for_user_enter
Methods included from RunCmd
Constructor Details
#initialize(tests_suite, game) ⇒ TestsSuite
Constructor
- Parameters
-
tests_suite (Symbol): The tests suite name
-
game (Game): The game for which this test type is instantiated
19 20 21 22 |
# File 'lib/modsvaskr/tests_suite.rb', line 19 def initialize(tests_suite, game) @tests_suite = tests_suite @game = game end |
Instance Method Details
#clear_tests ⇒ Object
Remove all tests from this suite
54 55 56 |
# File 'lib/modsvaskr/tests_suite.rb', line 54 def clear_tests FileUtils.rm_f(json_statuses_file) end |
#statuses ⇒ Object
Get test statuses
- Result
-
Array<[String, String]>: Ordered list of [test name, test status]
28 29 30 |
# File 'lib/modsvaskr/tests_suite.rb', line 28 def statuses File.exist?(json_statuses_file) ? JSON.parse(File.read(json_statuses_file)) : [] end |
#statuses=(statuses) ⇒ Object
Set test statuses. Add new ones and overwrites existing ones.
- Parameters
-
statuses (Array<[String, String]>): Ordered list of [test name, test status]
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/modsvaskr/tests_suite.rb', line 37 def statuses=(statuses) current_statuses = self.statuses statuses.each do |(test_name, test_status)| test_status_info = current_statuses.find { |(search_test_name, _search_test_status)| search_test_name == test_name } if test_status_info.nil? # New one. Add it to the end. current_statuses << [test_name, test_status] else # Already existing. Just change its status. test_status_info[1] = test_status end end FileUtils.mkdir_p File.dirname(json_statuses_file) File.write(json_statuses_file, JSON.pretty_generate(current_statuses)) end |