mirror of
https://github.com/inspec/inspec
synced 2024-11-30 16:39:20 +00:00
b4f772546b
* Fix to_s on directory resource The `to_s` method on the `directory` resource is not defined in the correct class, leading `directory` resources to be printed as the parent resource (`file`) instead. Signed-off-by: Adam Leff <adam@leff.co> * Directory existence should check to see if it's a directory Signed-off-by: Adam Leff <adam@leff.co>
25 lines
717 B
Ruby
25 lines
717 B
Ruby
# encoding: utf-8
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
|
|
require 'resources/file'
|
|
|
|
module Inspec::Resources
|
|
class Directory < FileResource
|
|
name 'directory'
|
|
desc 'Use the directory InSpec audit resource to test if the file type is a directory. This is equivalent to using the file InSpec audit resource and the be_directory matcher, but provides a simpler and more direct way to test directories. All of the matchers available to file may be used with directory.'
|
|
example "
|
|
describe directory('path') do
|
|
it { should be_directory }
|
|
end
|
|
"
|
|
|
|
def exist?
|
|
file.exist? && file.directory?
|
|
end
|
|
|
|
def to_s
|
|
"Directory #{source_path}"
|
|
end
|
|
end
|
|
end
|