lib/serverspec/backend/exec.rb in serverspec-0.2.4 vs lib/serverspec/backend/exec.rb in serverspec-0.2.5
- old
+ new
@@ -20,93 +20,40 @@
def check_zero(cmd, *args)
ret = do_check(commands.send(cmd, *args))
ret[:exit_code] == 0
end
- def check_directory(directory)
- check_zero(:check_directory, directory)
+ # Default action is to call check_zero with args
+ def method_missing(meth, *args, &block)
+ # Remove example object from *args
+ args.shift
+ check_zero(meth, *args)
end
- def check_enabled(service)
- check_zero(:check_enabled, service)
- end
-
- def check_file(file)
- check_zero(:check_file, file)
- end
-
- def check_group(group)
- check_zero(:check_group, group)
- end
-
- def check_grouped(file, group)
- check_zero(:check_grouped, file, group)
- end
-
- def check_installed(package)
- check_zero(:check_installed, package)
- end
-
- def check_installed_by_gem(package, version)
+ def check_installed_by_gem(example, package, version)
ret = do_check(commands.check_installed_by_gem(package))
res = ret[:exit_code] == 0
if res && version
res = false if not ret[:stdout].match(/\(#{version}\)/)
end
res
end
- def check_link(link, target)
- check_zero(:check_link, link, target)
- end
-
- def check_listening(port)
- check_zero(:check_listening, port)
- end
-
- def check_mode(file, mode)
- check_zero(:check_mode, file, mode)
- end
-
- def check_owner(file, owner)
- check_zero(:check_owner, file, owner)
- end
-
- def check_running(process)
+ def check_running(example, process)
ret = do_check(commands.check_running(process))
if ret[:exit_code] == 1 || ret[:stdout] =~ /stopped/
ret = do_check(commands.check_process(process))
end
ret[:exit_code] == 0
end
- def check_running_under_supervisor(process)
+ def check_running_under_supervisor(example, process)
ret = do_check(commands.check_running_under_supervisor(process))
ret[:exit_code] == 0 && ret[:stdout] =~ /RUNNING/
end
- def check_user(user)
- check_zero(:check_user, user)
- end
-
- def check_belonging_group(user, group)
- check_zero(:check_belonging_group, user, group)
- end
-
- def check_cron_entry(user, entry)
- check_zero(:check_cron_entry, user, entry)
- end
-
- def check_iptables_rule(rule, table, chain)
- check_zero(:check_iptables_rule, rule, table, chain)
- end
-
- def check_zfs(zfs, property)
- check_zero(:check_zfs, zfs, property)
- end
-
- def check_readable(file, by_whom)
+ def check_readable(example, file, by_whom)
mode = sprintf('%04s',do_check(commands.get_mode(file))[:stdout].strip)
mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
if by_whom.nil?
mode_octal & 0444 != 0
elsif by_whom == 'owner'
@@ -116,11 +63,11 @@
elsif by_whom == 'others'
mode_octal & 0004 != 0
end
end
- def check_writable(file, by_whom)
+ def check_writable(example, file, by_whom)
mode = sprintf('%04s',do_check(commands.get_mode(file))[:stdout].strip)
mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
if by_whom.nil?
mode_octal & 0222 != 0
elsif by_whom == 'owner'
@@ -130,10 +77,10 @@
elsif by_whom == 'others'
mode_octal & 0002 != 0
end
end
- def check_executable(file, by_whom)
+ def check_executable(example, file, by_whom)
mode = sprintf('%04s',do_check(commands.get_mode(file))[:stdout].strip)
mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
if by_whom.nil?
mode_octal & 0111 != 0
elsif by_whom == 'owner'