lib/specinfra/command/base/file.rb in specinfra-2.0.0.beta11 vs lib/specinfra/command/base/file.rb in specinfra-2.0.0.beta12
- old
+ new
@@ -9,12 +9,12 @@
def check_is_socket(file)
"test -S #{escape(file)}"
end
- def check_contain(file, expected_pattern)
- "#{check_file_contain_with_regexp(file, expected_pattern)} || #{check_file_contain_with_fixed_strings(file, expected_pattern)}"
+ def check_contains(file, expected_pattern)
+ "#{check_file_contains_with_regexp(file, expected_pattern)} || #{check_file_contains_with_fixed_strings(file, expected_pattern)}"
end
def check_is_grouped(file, group)
regexp = "^#{group}$"
"stat -c %G #{escape(file)} | grep -- #{escape(regexp)}"
@@ -23,39 +23,39 @@
def check_is_owned_by(file, owner)
regexp = "^#{owner}$"
"stat -c %U #{escape(file)} | grep -- #{escape(regexp)}"
end
- def check_mode(file, mode)
+ def check_has_mode(file, mode)
regexp = "^#{mode}$"
"stat -c %a #{escape(file)} | grep -- #{escape(regexp)}"
end
- def check_contain_within(file, expected_pattern, from=nil, to=nil)
+ def check_contains_within(file, expected_pattern, from=nil, to=nil)
from ||= '1'
to ||= '$'
sed = "sed -n #{escape(from)},#{escape(to)}p #{escape(file)}"
- checker_with_regexp = check_file_contain_with_regexp("-", expected_pattern)
- checker_with_fixed = check_file_contain_with_fixed_strings("-", expected_pattern)
+ checker_with_regexp = check_file_contains_with_regexp("-", expected_pattern)
+ checker_with_fixed = check_file_contains_with_fixed_strings("-", expected_pattern)
"#{sed} | #{checker_with_regexp} || #{sed} | #{checker_with_fixed}"
end
- def check_contain_lines(file, expected_lines, from=nil, to=nil)
+ def check_contains_lines(file, expected_lines, from=nil, to=nil)
require 'digest/md5'
from ||= '1'
to ||= '$'
sed = "sed -n #{escape(from)},#{escape(to)}p #{escape(file)}"
head_line = expected_lines.first.chomp
lines_checksum = Digest::MD5.hexdigest(expected_lines.map(&:chomp).join("\n") + "\n")
afterwards_length = expected_lines.length - 1
"#{sed} | grep -A #{escape(afterwards_length)} -F -- #{escape(head_line)} | md5sum | grep -qiw -- #{escape(lines_checksum)}"
end
- def check_contain_with_regexp(file, expected_pattern)
+ def check_contains_with_regexp(file, expected_pattern)
"grep -q -- #{escape(expected_pattern)} #{escape(file)}"
end
- def check_contain_with_fixed_strings(file, expected_pattern)
+ def check_contains_with_fixed_strings(file, expected_pattern)
"grep -qF -- #{escape(expected_pattern)} #{escape(file)}"
end
def check_has_md5checksum(file, expected)
regexp = "^#{expected}"