lib/specinfra/command/base/file.rb in specinfra-2.10.1 vs lib/specinfra/command/base/file.rb in specinfra-2.10.2

- old
+ new

@@ -24,15 +24,23 @@ "#{check_contains_with_regexp(file, expected_pattern)} || #{check_contains_with_fixed_strings(file, expected_pattern)}" end def check_is_grouped(file, group) regexp = "^#{group}$" - "stat -c %G #{escape(file)} | grep -- #{escape(regexp)}" + if group.is_a?(Numeric) || (group =~ /\A\d+\z/ ? true : false) + "stat -c %g #{escape(file)} | grep -- #{escape(regexp)}" + else + "stat -c %G #{escape(file)} | grep -- #{escape(regexp)}" + end end def check_is_owned_by(file, owner) regexp = "^#{owner}$" - "stat -c %U #{escape(file)} | grep -- #{escape(regexp)}" + if owner.is_a?(Numeric) || (owner =~ /\A\d+\z/ ? true : false) + "stat -c %u #{escape(file)} | grep -- #{escape(regexp)}" + else + "stat -c %U #{escape(file)} | grep -- #{escape(regexp)}" + end end def check_has_mode(file, mode) regexp = "^#{mode}$" "stat -c %a #{escape(file)} | grep -- #{escape(regexp)}"