Class: MiniTest::Unit::TestCase

Inherits:
Object
  • Object
show all
Includes:
Siba::FilePlug, SibaMinitestPlugin
Defined in:
lib/siba/helpers/test/siba_minitest_plugin.rb,
lib/siba/helpers/test/extend_test.rb

Instance Method Summary collapse

Methods included from Siba::FilePlug

#siba_file, siba_file, siba_file=

Methods included from SibaMinitestPlugin

#after_teardown, #before_setup

Instance Method Details

#create_plugin(yml_file_name_or_options_hash) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/siba/helpers/test/extend_test.rb', line 43

def create_plugin(yml_file_name_or_options_hash)
  if yml_file_name_or_options_hash.is_a? String
    load_options yml_file_name_or_options_hash
  else
    @options = yml_file_name_or_options_hash
  end

  unless @plugin_category
    raise Siba::Error, "Initialize '@plugin_category' variable (#{Siba::Plugins.categories_str})"
  end

  unless @plugin_type
    raise Siba::Error, "Initialize '@plugin_type' variable with your gem name ('cloud', 'ftp' etc)."
  end

  Siba::PluginLoader.loader.load(@plugin_category, @plugin_type, @options)
end

#dirs_same?(a, b) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/siba/helpers/test/extend_test.rb', line 89

def dirs_same?(a,b)
  Siba::FileHelper::dirs_same? a, b
end

#generate_path(file_name_part, tmp_dir = nil) ⇒ Object



79
80
81
82
# File 'lib/siba/helpers/test/extend_test.rb', line 79

def generate_path(file_name_part, tmp_dir = nil)
  tmp_dir ||= SibaTest.tmp_dir
  Siba::TestFiles::generate_path file_name_part, tmp_dir
end

#load_options(yml_name) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/siba/helpers/test/extend_test.rb', line 61

def load_options(yml_name)
  unless @yml_path
    raise Siba::Error, "Initialize '@yml_path' variable with the dir to test YAML files."
  end
  yml_name = yml_name + ".yml" unless yml_name =~ /\.yml$/
  @options = SibaTest.load_options File.join(@yml_path, yml_name)
end

#mkdir_in_tmp_dir(prefix, tmp_dir = nil) ⇒ Object



84
85
86
87
# File 'lib/siba/helpers/test/extend_test.rb', line 84

def mkdir_in_tmp_dir(prefix, tmp_dir = nil)
  tmp_dir ||= SibaTest.tmp_dir
  Siba::TestFiles::mkdir_in_tmp_dir prefix, tmp_dir
end

#mock_file(name, retval, args = []) ⇒ Object



33
34
35
36
37
# File 'lib/siba/helpers/test/extend_test.rb', line 33

def mock_file(name, retval, args=[])
  mock = new_mock_file
  mock.expect name, retval, args
  mock
end

#must_log(level) ⇒ Object



5
6
7
# File 'lib/siba/helpers/test/extend_test.rb', line 5

def must_log(level)
  verify_log true, level, true
end

#must_log_from(level) ⇒ Object



13
14
15
# File 'lib/siba/helpers/test/extend_test.rb', line 13

def must_log_from(level)
  verify_log true, level, false
end

#must_log_msg(msg, level) ⇒ Object



21
22
23
# File 'lib/siba/helpers/test/extend_test.rb', line 21

def must_log_msg(msg, level)
  verify_log_msg msg, true, level
end

#new_mock_fileObject



39
40
41
# File 'lib/siba/helpers/test/extend_test.rb', line 39

def new_mock_file
  Siba::FilePlug.siba_file = MiniTest::Mock.new
end

#prepare_options(src_yml_path, replace_data) ⇒ Object



93
94
95
# File 'lib/siba/helpers/test/extend_test.rb', line 93

def prepare_options(src_yml_path, replace_data)
  Siba::TestFiles::prepare_options(src_yml_path, replace_data)
end

#prepare_test_dir(dir_name_part, tmp_dir = nil) ⇒ Object



69
70
71
72
# File 'lib/siba/helpers/test/extend_test.rb', line 69

def prepare_test_dir(dir_name_part, tmp_dir = nil)
  tmp_dir ||= SibaTest.tmp_dir
  Siba::TestFiles::prepare_test_dir dir_name_part, tmp_dir
end

#prepare_test_file(file_name_part, tmp_dir = nil) ⇒ Object



74
75
76
77
# File 'lib/siba/helpers/test/extend_test.rb', line 74

def prepare_test_file(file_name_part, tmp_dir = nil)
  tmp_dir ||= SibaTest.tmp_dir
  Siba::TestFiles::prepare_test_file file_name_part, tmp_dir
end

#prepare_yml(src_yml_path, replace_data, tmp_dir = nil) ⇒ Object



97
98
99
100
# File 'lib/siba/helpers/test/extend_test.rb', line 97

def prepare_yml(src_yml_path, replace_data, tmp_dir=nil)
  tmp_dir ||= SibaTest.tmp_dir
  Siba::TestFiles::prepare_yml src_yml_path, replace_data, tmp_dir
end

#show_logObject



29
30
31
# File 'lib/siba/helpers/test/extend_test.rb', line 29

def show_log
  puts Siba::SibaLogger.messages.map{|a| a.msg}.join("\n")
end

#wont_log(level) ⇒ Object



9
10
11
# File 'lib/siba/helpers/test/extend_test.rb', line 9

def wont_log(level)
  verify_log false, level, true
end

#wont_log_from(level) ⇒ Object



17
18
19
# File 'lib/siba/helpers/test/extend_test.rb', line 17

def wont_log_from(level)
  verify_log false, level, false
end

#wont_log_msg(msg, level) ⇒ Object



25
26
27
# File 'lib/siba/helpers/test/extend_test.rb', line 25

def wont_log_msg(msg, level)
  verify_log_msg msg, false, level
end