Class: MiniTest::Unit::TestCase
- Inherits:
-
Object
- Object
- MiniTest::Unit::TestCase
show all
- Includes:
- Siba::FilePlug
- Defined in:
- lib/siba/helpers/test/extend_test.rb
Instance Method Summary
collapse
-
#create_plugin(yml_file_name_or_options_hash) ⇒ Object
-
#dirs_same?(a, b) ⇒ Boolean
-
#generate_path(file_name_part, tmp_dir = nil) ⇒ Object
-
#load_options(yml_name) ⇒ Object
-
#mkdir_in_tmp_dir(prefix, tmp_dir = nil) ⇒ Object
-
#mock_file(name, retval, args = []) ⇒ Object
-
#must_log(level) ⇒ Object
-
#must_log_from(level) ⇒ Object
-
#new_mock_file ⇒ Object
-
#prepare_options(src_yml_path, replace_data) ⇒ Object
-
#prepare_test_dir(dir_name_part, tmp_dir = nil) ⇒ Object
-
#prepare_test_file(file_name_part, tmp_dir = nil) ⇒ Object
-
#prepare_yml(src_yml_path, replace_data, tmp_dir = nil) ⇒ Object
-
#show_log ⇒ Object
-
#wont_log(level) ⇒ Object
-
#wont_log_from(level) ⇒ Object
#siba_file, siba_file, siba_file=
Instance Method Details
#create_plugin(yml_file_name_or_options_hash) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/siba/helpers/test/extend_test.rb', line 35
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
81
82
83
|
# File 'lib/siba/helpers/test/extend_test.rb', line 81
def dirs_same?(a,b)
Siba::FileHelper::dirs_same? a, b
end
|
#generate_path(file_name_part, tmp_dir = nil) ⇒ Object
71
72
73
74
|
# File 'lib/siba/helpers/test/extend_test.rb', line 71
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
53
54
55
56
57
58
59
|
# File 'lib/siba/helpers/test/extend_test.rb', line 53
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
76
77
78
79
|
# File 'lib/siba/helpers/test/extend_test.rb', line 76
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
25
26
27
28
29
|
# File 'lib/siba/helpers/test/extend_test.rb', line 25
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
|
#new_mock_file ⇒ Object
31
32
33
|
# File 'lib/siba/helpers/test/extend_test.rb', line 31
def new_mock_file
Siba::FilePlug.siba_file = MiniTest::Mock.new
end
|
#prepare_options(src_yml_path, replace_data) ⇒ Object
85
86
87
|
# File 'lib/siba/helpers/test/extend_test.rb', line 85
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
61
62
63
64
|
# File 'lib/siba/helpers/test/extend_test.rb', line 61
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
66
67
68
69
|
# File 'lib/siba/helpers/test/extend_test.rb', line 66
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
89
90
91
92
|
# File 'lib/siba/helpers/test/extend_test.rb', line 89
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_log ⇒ Object
21
22
23
|
# File 'lib/siba/helpers/test/extend_test.rb', line 21
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
|