module SibaTest

Helper used to re-init constants Based on stackoverflow.com/questions/3375360/how-to-redefine-a-ruby-constant-without-warning

Constants

IS_WINDOWS
TmpDirMocked
UNICODE_FILE_NAME

Attributes

setup_hooks[RW]
teardown_hooks[RW]

Public Class Methods

init() click to toggle source
# File lib/siba/helpers/test/helper.rb, line 14
def init
  require 'minitest/pride' unless SibaTest::IS_WINDOWS

  @loaded_options = {}
  @current_dir = siba_file.file_utils_pwd
  @setup_hooks = []
  @teardown_hooks = []

  @setup_hooks << -> do
    Siba::SibaLogger.quiet = true
    Siba::SibaLogger.no_log = true
    Siba::LoggerPlug.create "Test", nil
    Siba::SibaLogger.messages = []
    Siba.settings = {}
    Siba.current_dir = @current_dir
    Siba.backup_name = "siba"
    SibaTest::KernelMock.mock_all_methods # prevents tests from accessing Kernel methods
  end

  @teardown_hooks << -> { Siba::LoggerPlug.close }
end
init_integration() click to toggle source
# File lib/siba/helpers/test/helper.rb, line 44
def init_integration
  init
  @teardown_hooks << -> do
    # cleanup after each integration test
    Siba.current_dir = @current_dir
    Siba.cleanup_tmp_dir
    SibaTest.cleanup_tmp_dir
  end
end
init_unit() click to toggle source
# File lib/siba/helpers/test/helper.rb, line 36
def init_unit
  init
  @setup_hooks << -> 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) click to toggle source
# File lib/siba/helpers/test/helper.rb, line 54
def load_options(path_to_yml)
  @loaded_options[path_to_yml] ||= Siba::OptionsLoader.load_yml(path_to_yml)
end