summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2016-09-14 14:00:41 -0700
committerTim Smith <tsmith@chef.io>2016-09-14 14:00:41 -0700
commita15331a44d3fe1885c4c787055cba4d2e424e6c6 (patch)
tree66c36fcc164c515264fa0c973aa6abb03ae45a0b
parent1e8796cda6c1602df2d7d2107df32a650b678d75 (diff)
downloadchef-a15331a44d3fe1885c4c787055cba4d2e424e6c6.tar.gz
Test apt_update on non-linux behavior
Make sure on non-linux without running which we still end up with a no-op Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--spec/unit/resource/apt_update_spec.rb42
1 files changed, 25 insertions, 17 deletions
diff --git a/spec/unit/resource/apt_update_spec.rb b/spec/unit/resource/apt_update_spec.rb
index dd72b18063..a7d2c64fee 100644
--- a/spec/unit/resource/apt_update_spec.rb
+++ b/spec/unit/resource/apt_update_spec.rb
@@ -24,27 +24,35 @@ describe Chef::Resource::AptUpdate do
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:resource) { Chef::Resource::AptUpdate.new("update", run_context) }
- it "should create a new Chef::Resource::AptUpdate" do
- expect(resource).to be_a_kind_of(Chef::Resource)
- expect(resource).to be_a_kind_of(Chef::Resource::AptUpdate)
- end
+ context "on linux", :linux_only do
+ it "should create a new Chef::Resource::AptUpdate" do
+ expect(resource).to be_a_kind_of(Chef::Resource)
+ expect(resource).to be_a_kind_of(Chef::Resource::AptUpdate)
+ end
- it "the default frequency should be 1 day" do
- expect(resource.frequency).to eql(86_400)
- end
+ it "the default frequency should be 1 day" do
+ expect(resource.frequency).to eql(86_400)
+ end
- it "the frequency should accept integers" do
- resource.frequency(400)
- expect(resource.frequency).to eql(400)
- end
+ it "the frequency should accept integers" do
+ resource.frequency(400)
+ expect(resource.frequency).to eql(400)
+ end
+
+ it "should resolve to a Noop class when apt-get is not found" do
+ expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(false)
+ expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop)
+ end
- it "should resolve to a Noop class when apt-get is not found" do
- expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(false)
- expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop)
+ it "should resolve to a AptUpdate class when apt-get is found" do
+ expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(true)
+ expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::AptUpdate)
+ end
end
- it "should resolve to a AptUpdate class when apt-get is found" do
- expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(true)
- expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::AptUpdate)
+ context "on windows", :windows_only do
+ it "should resolve to a NoOp provider" do
+ expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop)
+ end
end
end