summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/resource/cab_package_spec.rb25
-rw-r--r--spec/unit/resource/msu_package_spec.rb25
2 files changed, 42 insertions, 8 deletions
diff --git a/spec/unit/resource/cab_package_spec.rb b/spec/unit/resource/cab_package_spec.rb
index aa4890f171..167cf6e86e 100644
--- a/spec/unit/resource/cab_package_spec.rb
+++ b/spec/unit/resource/cab_package_spec.rb
@@ -32,7 +32,30 @@ describe Chef::Resource::CabPackage do
expect(resource.resource_name).to eql(:cab_package)
end
- it "coerce its name to a package_name" do
+ it "sets the default action as :install" do
+ expect(resource.action).to eql([:install])
+ end
+
+ it "coerces name property to package_name property" do
expect(resource.package_name).to eql("test_pkg")
end
+
+ it "coerces name property to a source property if source not provided" do
+ expect(resource.source).to end_with("test_pkg")
+ end
+
+ it "coerces name property to a source property if source not provided and package_name is" do
+ resource.package_name("package.cab")
+ expect(resource.source).to end_with("package.cab")
+ end
+
+ it "does not coerce the source property if it looks like a path" do
+ resource.source("/foo/bar/package.cab")
+ expect(resource.source).to eq("/foo/bar/package.cab")
+ end
+
+ it "coerces source property if it does not looks like a path" do
+ resource.source("package.cab")
+ expect(resource.source).not_to eq("package.cab")
+ end
end
diff --git a/spec/unit/resource/msu_package_spec.rb b/spec/unit/resource/msu_package_spec.rb
index 66aacbc020..e32fab897d 100644
--- a/spec/unit/resource/msu_package_spec.rb
+++ b/spec/unit/resource/msu_package_spec.rb
@@ -31,19 +31,30 @@ describe Chef::Resource::MsuPackage do
expect(resource.resource_name).to eql(:msu_package)
end
- it "sets the source as its name and then coerces it to a path" do
+ it "sets the default action as :install" do
+ expect(resource.action).to eql([:install])
+ end
+
+ it "coerces name property to package_name property" do
+ expect(resource.package_name).to eql("test_pkg")
+ end
+
+ it "coerces name property to a source property if source not provided" do
expect(resource.source).to end_with("test_pkg")
end
- it "sets the default action as :install" do
- expect(resource.action).to eql([:install])
+ it "coerces name property to a source property if source not provided and package_name is" do
+ resource.package_name("package.msu")
+ expect(resource.source).to end_with("package.msu")
end
- it "raises error if invalid action is given" do
- expect { resource.action :abc }.to raise_error(Chef::Exceptions::ValidationFailed)
+ it "does not coerce the source property if it looks like a path" do
+ resource.source("/foo/bar/package.msu")
+ expect(resource.source).to eq("/foo/bar/package.msu")
end
- it "coerce its name to a package_name" do
- expect(resource.package_name).to eql("test_pkg")
+ it "coerces source property if it does not looks like a path" do
+ resource.source("package.msu")
+ expect(resource.source).not_to eq("package.msu")
end
end