diff options
author | danielsdeleo <dan@opscode.com> | 2013-01-07 16:17:30 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-01-07 16:17:30 -0800 |
commit | fb30e1659d70f8d16c3809c654f1afc5eda33946 (patch) | |
tree | 46a95046b6db7484ad9146398b23ebd56b13b10f | |
parent | 3d2ffb5a03e1100de19a4cd91581e7cfa0fcf4ef (diff) | |
parent | 9a2a474553d8595f7ba6ad4515fe24b92ee8c5aa (diff) | |
download | chef-fb30e1659d70f8d16c3809c654f1afc5eda33946.tar.gz |
Merge branch 'fix-reporting-tests-windows'
-rw-r--r-- | spec/unit/provider/directory_spec.rb | 21 | ||||
-rw-r--r-- | spec/unit/provider/file_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/provider/template_spec.rb | 32 |
3 files changed, 40 insertions, 16 deletions
diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb index 722a451a7b..ef35f1346b 100644 --- a/spec/unit/provider/directory_spec.rb +++ b/spec/unit/provider/directory_spec.rb @@ -47,6 +47,9 @@ describe Chef::Provider::Directory do end describe "scanning file security metadata on unix" do + before do + Chef::Platform.stub!(:windows?).and_return(false) + end let(:mock_stat) do cstats = mock("stats") cstats.stub!(:uid).and_return(500) @@ -77,10 +80,15 @@ describe Chef::Provider::Directory do end end - it "should create a new directory on create, setting updated to true" do + # Unix only for now. While file security attribute reporting for windows is + # disabled, unix and windows differ in the number of exist? calls that are + # made by the provider. + it "should create a new directory on create, setting updated to true", :unix_only do @new_resource.path "/tmp/foo" File.should_receive(:exist?).exactly(2).and_return(false) + File.should_receive(:directory?).with("/tmp").and_return(true) + File.should_receive(:writeable?).with("/tmp").and_return(true) Dir.should_receive(:mkdir).with(@new_resource.path).once.and_return(true) @directory.should_receive(:set_all_access_controls) @@ -95,7 +103,10 @@ describe Chef::Provider::Directory do lambda { @directory.run_action(:create) }.should raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist) end - it "should create a new directory when parent directory does not exist if recursive is true and permissions are correct" do + # Unix only for now. While file security attribute reporting for windows is + # disabled, unix and windows differ in the number of exist? calls that are + # made by the provider. + it "should create a new directory when parent directory does not exist if recursive is true and permissions are correct", :unix_only do @new_resource.path "/path/to/dir" @new_resource.recursive true File.should_receive(:exist?).with(@new_resource.path).ordered.and_return(false) @@ -120,10 +131,14 @@ describe Chef::Provider::Directory do @directory.new_resource.should_not be_updated end - it "should not create the directory if it already exists" do + # Unix only for now. While file security attribute reporting for windows is + # disabled, unix and windows differ in the number of exist? calls that are + # made by the provider. + it "should not create the directory if it already exists", :unix_only do stub_file_cstats @new_resource.path "/tmp/foo" File.should_receive(:directory?).twice.and_return(true) + File.should_receive(:writable?).with("/tmp").and_return(true) File.should_receive(:exist?).exactly(3).and_return(true) Dir.should_not_receive(:mkdir).with(@new_resource.path) @directory.should_receive(:set_all_access_controls) diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index 9dc3908bad..5b1cbbbdb8 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -54,6 +54,9 @@ describe Chef::Provider::File do end describe "examining file security metadata on Unix" do + before do + Chef::Platform.stub!(:windows?).and_return(false) + end it "should collect the current state of the file on the filesystem and populate current_resource" do # test setup stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000) diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb index 5f59f8d50e..b709d8e612 100644 --- a/spec/unit/provider/template_spec.rb +++ b/spec/unit/provider/template_spec.rb @@ -117,19 +117,25 @@ describe Chef::Provider::Template do end context "and no access control settings are set on the resource" do - it "sets access control metadata on the new resource" do - @access_controls.stub!(:requires_changes?).and_return(false) - @access_controls.should_receive(:set_all!) - @node.normal[:slappiness] = "happiness" - @provider.should_receive(:backup) - @provider.run_action(:create) - IO.read(@rendered_file_location).should == "slappiness is happiness" - @resource.should be_updated_by_last_action - - # Veracity of actual data checked in functional tests - @resource.owner.should be_a_kind_of(String) - @resource.group.should be_a_kind_of(String) - @resource.mode.should be_a_kind_of(String) + context "on a Unix system" do + before do + Chef::Platform.stub!(:windows?).and_return(false) + end + + it "sets access control metadata on the new resource" do + @access_controls.stub!(:requires_changes?).and_return(false) + @access_controls.should_receive(:set_all!) + @node.normal[:slappiness] = "happiness" + @provider.should_receive(:backup) + @provider.run_action(:create) + IO.read(@rendered_file_location).should == "slappiness is happiness" + @resource.should be_updated_by_last_action + + # Veracity of actual data checked in functional tests + @resource.owner.should be_a_kind_of(String) + @resource.group.should be_a_kind_of(String) + @resource.mode.should be_a_kind_of(String) + end end end end |