Created
October 1, 2012 20:56
-
-
Save dougireton/3814352 to your computer and use it in GitHub Desktop.
Chefspec doesn't seem to support Windows 'rights' attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When I run this spec, I get errors saying undefined method `rights' for Chef::Resource::CookbookFile since I'm using the [Windows 'rights' attribute](http://wiki.opscode.com/display/chef/Improved+Windows+File+Security) | |
Does chefspec support the Windows 'rights' attribute? | |
```ruby | |
require 'chefspec' | |
describe 'hosts_file::windows' do | |
let(:chef_run) { ChefSpec::ChefRunner.new } | |
it 'installs the default Windows hosts file' do | |
chef_run.node.automatic_attrs[:platform] = 'windows' | |
chef_run.converge 'hosts_file::windows' | |
expect(chef_run).to create_file 'C:/windows/system32/drivers/etc/hosts' | |
end | |
end | |
``` | |
$ rspec spec/windows_spec.rb -c -fd | |
hosts_file::windows | |
Recipe Compile Error in /cookbooks/hosts_file/recipes/windows.rb | |
NoMethodError | |
------------- | |
undefined method `rights' for Chef::Resource::CookbookFile | |
Cookbook Trace: | |
--------------- | |
/cookbooks/hosts_file/recipes/windows.rb:8:in `block in from_file' | |
/cookbooks/hosts_file/recipes/windows.rb:6:in `from_file' | |
/cookbooks/hosts_file/spec/windows_spec.rb:9:in `block (2 levels) in <top (required)>' | |
Relevant File Content: | |
---------------------- | |
/cookbooks/hosts_file/recipes/windows.rb: | |
```ruby | |
5: | |
6: cookbook_file "#{ENV["systemroot"]}/system32/drivers/etc/hosts" do | |
7: source "#{node["hosts_file"]["name"]}#{node["hosts_file"]["suffix"]}" | |
8>> rights :full_control, "Administrators" | |
9: rights :full_control, "SYSTEM" | |
10: rights :read, "Users" | |
11: end | |
12: | |
``` | |
installs the default Windows hosts file (FAILED - 1) | |
Failures: | |
1) hosts_file::windows installs the default Windows hosts file | |
Failure/Error: chef_run.converge 'hosts_file::windows' | |
NoMethodError: | |
undefined method `rights' for Chef::Resource::CookbookFile | |
# ./recipes/windows.rb:8:in `block in from_file' | |
# ./recipes/windows.rb:6:in `from_file' | |
# ./spec/windows_spec.rb:9:in `block (2 levels) in <top (required)>' | |
Finished in 0.00932 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/windows_spec.rb:7 # hosts_file::windows installs the default Windows hosts file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment