lib/specinfra/command/base/file.rb in specinfra-2.0.0.beta32 vs lib/specinfra/command/base/file.rb in specinfra-2.0.0.beta33
- old
+ new
@@ -33,13 +33,14 @@
def check_contains_within(file, expected_pattern, from=nil, to=nil)
from ||= '1'
to ||= '$'
sed = "sed -n #{escape(from)},#{escape(to)}p #{escape(file)}"
+ sed_end = "sed -n 1,#{escape(to)}p"
checker_with_regexp = check_contains_with_regexp("-", expected_pattern)
checker_with_fixed = check_contains_with_fixed_strings("-", expected_pattern)
- "#{sed} | #{checker_with_regexp} || #{sed} | #{checker_with_fixed}"
+ "#{sed} | #{sed_end} | #{checker_with_regexp} || #{sed} | #{sed_end} | #{checker_with_fixed}"
end
def check_contains_lines(file, expected_lines, from=nil, to=nil)
require 'digest/md5'
from ||= '1'
@@ -50,14 +51,14 @@
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_contains_with_regexp(file, expected_pattern)
- "grep -q -- #{escape(expected_pattern)} #{escape(file)}"
+ "grep -qs -- #{escape(expected_pattern)} #{escape(file)}"
end
def check_contains_with_fixed_strings(file, expected_pattern)
- "grep -qF -- #{escape(expected_pattern)} #{escape(file)}"
+ "grep -qFs -- #{escape(expected_pattern)} #{escape(file)}"
end
def get_md5sum(file)
"md5sum #{escape(file)} | cut -d ' ' -f 1"
end