Module: SibaTest
- Extended by:
- Siba::TmpDirPlug
- Defined in:
- lib/siba/helpers/test/removable_constants.rb,
lib/siba/helpers/test/helper.rb,
lib/siba/helpers/test/file_mock.rb,
lib/siba/helpers/test/kernel_mock.rb
Overview
Helper used to re-init constants Based on stackoverflow.com/questions/3375360/how-to-redefine-a-ruby-constant-without-warning
Defined Under Namespace
Modules: RemovableConstants Classes: FileMock, KernelMock
Constant Summary collapse
- IS_WINDOWS =
!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/).nil?
- UNICODE_FILE_NAME =
"алиен学"
- TmpDirMocked =
"/tmp"
Class Method Summary collapse
Methods included from Siba::TmpDirPlug
cleanup_tmp_dir, tmp_dir, tmp_dir_clean?
Methods included from Siba::LoggerPlug
close, create, logger, #logger, opened?
Methods included from Siba::FilePlug
#siba_file, siba_file, siba_file=
Class Method Details
.init ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/siba/helpers/test/helper.rb', line 11 def init require 'minitest/pride' unless SibaTest::IS_WINDOWS @loaded_options = {} @current_dir = siba_file.file_utils_pwd MiniTest::Unit::TestCase.add_setup_hook do Siba::SibaLogger.quiet = true Siba::SibaLogger.no_log = true Siba::LoggerPlug.create "Test", nil Siba::SibaLogger. = [] Siba.settings = {} Siba.current_dir = @current_dir Siba.backup_name = "siba" SibaTest::KernelMock.mock_all_methods # prevents tests from accessing Kernel methods end MiniTest::Unit::TestCase.add_teardown_hook do Siba::LoggerPlug.close end end |
.init_integration ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/siba/helpers/test/helper.rb', line 41 def init_integration init MiniTest::Unit::TestCase.add_teardown_hook do # cleanup after each integration test Siba.current_dir = @current_dir Siba.cleanup_tmp_dir SibaTest.cleanup_tmp_dir end end |
.init_unit ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/siba/helpers/test/helper.rb', line 33 def init_unit init MiniTest::Unit::TestCase.add_setup_hook do SibaTest::FileMock.mock_all_methods # prevents tests from doing file operations Siba.class_eval {@tmp_dir = SibaTest::TmpDirMocked} end end |
.load_options(path_to_yml) ⇒ Object
51 52 53 |
# File 'lib/siba/helpers/test/helper.rb', line 51 def (path_to_yml) @loaded_options[path_to_yml] ||= Siba::OptionsLoader.load_yml(path_to_yml) end |