summaryrefslogtreecommitdiff
path: root/spec/unit/cookbook/metadata_spec.rb
diff options
context:
space:
mode:
authorBrett Chalupa <brettchalupa@gmail.com>2014-08-26 10:51:50 -0400
committerBrett Chalupa <brettchalupa@gmail.com>2014-08-26 10:51:50 -0400
commitfe6d60f7a9456a97457f37a20729e366a714f428 (patch)
tree9269368100c0990fe39d7c2c78b9ebbe996ae028 /spec/unit/cookbook/metadata_spec.rb
parentcd234b739550d4dce76cca0e5b5b247cff1c9ac7 (diff)
downloadchef-fe6d60f7a9456a97457f37a20729e366a714f428.tar.gz
Use individual URL attributes in metadata
Instead of having an arbitrary Hash/Mash of supermarket_attributes, use two explicit URL attributes at the top level of the metadata: the source_url and issues_url.
Diffstat (limited to 'spec/unit/cookbook/metadata_spec.rb')
-rw-r--r--spec/unit/cookbook/metadata_spec.rb56
1 files changed, 36 insertions, 20 deletions
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index a99131e33e..8f287a5b13 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -29,7 +29,8 @@ describe Chef::Cookbook::Metadata do
@fields = [ :name, :description, :long_description, :maintainer,
:maintainer_email, :license, :platforms, :dependencies,
:recommendations, :suggestions, :conflicting, :providing,
- :replacing, :attributes, :groupings, :recipes, :version]
+ :replacing, :attributes, :groupings, :recipes, :version,
+ :source_url, :issues_url ]
end
it "does not depend on object identity for equality" do
@@ -140,8 +141,12 @@ describe Chef::Cookbook::Metadata do
metadata.recipes.should eq(Mash.new)
end
- it "has an empty supermarket_attributes list" do
- metadata.supermarket_attributes.should eq(Mash.new)
+ it "has an empty source_url string" do
+ metadata.source_url.should eq('')
+ end
+
+ it "has an empty issues_url string" do
+ metadata.issues_url.should eq('')
end
end
@@ -191,7 +196,9 @@ describe Chef::Cookbook::Metadata do
:license => "Apache v2.0",
:description => "Foobar!",
:long_description => "Much Longer\nSeriously",
- :version => "0.6.0"
+ :version => "0.6.0",
+ :source_url => "http://example.com",
+ :issues_url => "http://example.com/issues"
}
params.sort { |a,b| a.to_s <=> b.to_s }.each do |field, field_value|
describe field do
@@ -336,7 +343,9 @@ describe Chef::Cookbook::Metadata do
"type" => 'string',
"required" => 'recommended',
"recipes" => [ "mysql::server", "mysql::master" ],
- "default" => [ ]
+ "default" => [ ],
+ "source_url" => "http://example.com",
+ "issues_url" => "http://example.com/issues"
}
metadata.attribute("/db/mysql/databases", attrs).should == attrs
end
@@ -359,6 +368,24 @@ describe Chef::Cookbook::Metadata do
}.should raise_error(ArgumentError)
end
+ it "should not accept anything but a string for the source_url" do
+ lambda {
+ metadata.attribute("db/mysql/databases", :source_url => "foo")
+ }.should_not raise_error
+ lambda {
+ metadata.attribute("db/mysql/databases", :source_url => Hash.new)
+ }.should raise_error(ArgumentError)
+ end
+
+ it "should not accept anything but a string for the issues_url" do
+ lambda {
+ metadata.attribute("db/mysql/databases", :issues_url => "foo")
+ }.should_not raise_error
+ lambda {
+ metadata.attribute("db/mysql/databases", :issues_url => Hash.new)
+ }.should raise_error(ArgumentError)
+ end
+
it "should not accept anything but an array of strings for choice" do
lambda {
metadata.attribute("db/mysql/databases", :choice => ['dedicated', 'shared'])
@@ -651,6 +678,8 @@ describe Chef::Cookbook::Metadata do
attributes
recipes
version
+ source_url
+ issues_url
}.each do |t|
it "should include '#{t}'" do
deserialized_metadata[t].should == metadata.send(t.to_sym)
@@ -684,6 +713,8 @@ describe Chef::Cookbook::Metadata do
attributes
recipes
version
+ source_url
+ issues_url
}.each do |t|
it "should match '#{t}'" do
deserialized_metadata.send(t.to_sym).should == metadata.send(t.to_sym)
@@ -734,19 +765,4 @@ describe Chef::Cookbook::Metadata do
end
end
-
- describe "supermarket_attributes" do
- it "should set supermarket_attributes equal to a given hash" do
- attrs = Mash.new(
- :source_url => "https://github.com/opscode-cookbooks/supermarket",
- :issues_url => "https://github.com/opscode-cookbooks/supermarket/issues"
- )
-
- metadata.supermarket_attributes(attrs)
-
- metadata.supermarket_attributes[:source_url].should == attrs[:source_url]
- metadata.supermarket_attributes[:issues_url].should == attrs[:issues_url]
- end
- end
-
end