Class: Chef::Resource::File

Inherits:
Chef::Resource show all
Defined in:
lib/chef/handler/resources/file.rb

Direct Known Subclasses

CookbookFile, Template

Instance Method Summary collapse

Instance Method Details

#to_serverspecObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/chef/handler/resources/file.rb', line 4

def to_serverspec
  ERB.new(
    <<-EOT,

  describe file('#{path}') do
<%- unless action.include? :delete -%>
    it { should be_file }
    it { should be_mode '#{mode}' }
    it { should be_owned_by '#{owner}' }
    it { should be_grouped_into '#{group}' }
    its(:content) do
should match <<EOF
#{::File.read(path) if ::File.exist?(path)}
EOF
    end
<%- else -%>
    it { should_not be_file }
<%- end -%>
  end
EOT
    safe_level = nil, trim_mode = '-').result(binding)
end