From 0bb30766e6f6fe1832343132b3433533e7b314a0 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 22 Jan 2015 14:12:14 -0800 Subject: added support for custom tests in files/tests --- lib/leap_cli/util.rb | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'lib/leap_cli/util.rb') diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb index ce5471c..9edb150 100644 --- a/lib/leap_cli/util.rb +++ b/lib/leap_cli/util.rb @@ -97,6 +97,23 @@ module LeapCli return output end + def assert_config!(conf_path) + value = nil + begin + value = manager.instance_eval(conf_path) + #rescue NoMethodError + #rescue NameError + ensure + assert! !value.nil? && value != "REQUIRED" do + log :missing, "required configuration value for #{conf_path}" + end + end + end + + ## + ## FILES AND DIRECTORIES + ## + def assert_files_missing!(*files) options = files.last.is_a?(Hash) ? files.pop : {} base = options[:base] || Path.provider @@ -117,19 +134,6 @@ module LeapCli end end - def assert_config!(conf_path) - value = nil - begin - value = manager.instance_eval(conf_path) - #rescue NoMethodError - #rescue NameError - ensure - assert! !value.nil? && value != "REQUIRED" do - log :missing, "required configuration value for #{conf_path}" - end - end - end - def assert_files_exist!(*files) options = files.last.is_a?(Hash) ? files.pop : {} file_list = files.collect { |file_path| @@ -149,6 +153,7 @@ module LeapCli end end + # takes a list of symbolic paths. returns true if all files exist or are directories. def file_exists?(*files) files.each do |file_path| file_path = Path.named_path(file_path) @@ -159,9 +164,16 @@ module LeapCli return true end - ## - ## FILES AND DIRECTORIES - ## + # takes a list of symbolic paths. returns true if all are directories. + def dir_exists?(*dirs) + dirs.each do |dir_path| + dir_path = Path.named_path(dir_path) + if !Dir.exists?(dir_path) + return false + end + end + return true + end # # creates a directory if it doesn't already exist -- cgit v1.2.3