summaryrefslogtreecommitdiff
path: root/spec/unit/cookbook_version_spec.rb
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2014-10-04 14:17:40 -0700
committerNoah Kantrowitz <noah@coderanger.net>2014-10-04 14:17:40 -0700
commitbb1fdc4f9ee114f6fd4d7783f6f32f9baa03cb7d (patch)
treeff3a15df353e00082dc2ff27b1bd16cba5d508fa /spec/unit/cookbook_version_spec.rb
parent2a18b135f2d0337e4fa23fd1fa9aa2071807b090 (diff)
downloadchef-bb1fdc4f9ee114f6fd4d7783f6f32f9baa03cb7d.tar.gz
Fix up the tests post-merge.
Diffstat (limited to 'spec/unit/cookbook_version_spec.rb')
-rw-r--r--spec/unit/cookbook_version_spec.rb90
1 files changed, 54 insertions, 36 deletions
diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb
index 4ee73151b4..c6fa00393c 100644
--- a/spec/unit/cookbook_version_spec.rb
+++ b/spec/unit/cookbook_version_spec.rb
@@ -98,12 +98,11 @@ describe Chef::CookbookVersion do
describe "with a cookbook directory named tatft" do
MD5 = /[0-9a-f]{32}/
- let(:cookbook) { 'taftft' }
before do
@cookbook = Hash.new { |hash, key| hash[key] = [] }
- @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', cookbook)
+ @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'tatft')
# Dunno if the paths here are representitive of what is set by CookbookLoader...
@cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, 'attributes', '**', '*.rb')]
@@ -122,7 +121,7 @@ describe Chef::CookbookVersion do
before do
# Currently the cookbook loader finds all the files then tells CookbookVersion
# where they are.
- @cookbook_version = Chef::CookbookVersion.new(cookbook, @cookbook_root)
+ @cookbook_version = Chef::CookbookVersion.new('tatft', @cookbook_root)
@cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
@cookbook_version.definition_filenames = @cookbook[:definition_filenames]
@@ -350,48 +349,67 @@ describe Chef::CookbookVersion do
readme["specificity"].should == "default"
end
end
+ end
- context 'when the cookbook has un-scoped files/templates' do
- let(:cookbook) { 'cookbook2' }
+ describe 'with a cookbook directory named cookbook2 that has unscoped files' do
+ before do
+ @cookbook = Hash.new { |hash, key| hash[key] = [] }
- before do
- @cookbook_version = Chef::CookbookVersion.new(cookbook, @cookbook_root)
- @cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
- @cookbook_version.definition_filenames = @cookbook[:definition_filenames]
- @cookbook_version.recipe_filenames = @cookbook[:recipe_filenames]
- @cookbook_version.template_filenames = @cookbook[:template_filenames]
- @cookbook_version.file_filenames = @cookbook[:file_filenames]
- @cookbook_version.library_filenames = @cookbook[:library_filenames]
- @cookbook_version.resource_filenames = @cookbook[:resource_filenames]
- @cookbook_version.provider_filenames = @cookbook[:provider_filenames]
- @cookbook_version.root_filenames = @cookbook[:root_filenames]
- @cookbook_version.metadata_filenames = @cookbook[:metadata_filenames]
- end
+ @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'cookbook2')
- it "should see a template" do
- @cookbook_version.should have_template_for_node(@node, "test.erb")
- end
+ # Dunno if the paths here are representitive of what is set by CookbookLoader...
+ @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, 'attributes', '**', '*.rb')]
+ @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, 'definitions', '**', '*.rb')]
+ @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, 'files', '**', '*.*')]
+ @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, 'recipes', '**', '*.rb')]
+ @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, 'templates', '**', '*.*')]
+ @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, 'libraries', '**', '*.rb')]
+ @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, 'resources', '**', '*.rb')]
+ @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, 'providers', '**', '*.rb')]
+ @cookbook[:root_filenames] = Array(File.join(@cookbook_root, 'README.rdoc'))
+ @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, 'metadata.json'))
- it "should see a template using an array lookup" do
- @cookbook_version.should have_template_for_node(@node, ["test.erb"])
- end
+ @cookbook_version = Chef::CookbookVersion.new('cookbook2', @cookbook_root)
+ @cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
+ @cookbook_version.definition_filenames = @cookbook[:definition_filenames]
+ @cookbook_version.recipe_filenames = @cookbook[:recipe_filenames]
+ @cookbook_version.template_filenames = @cookbook[:template_filenames]
+ @cookbook_version.file_filenames = @cookbook[:file_filenames]
+ @cookbook_version.library_filenames = @cookbook[:library_filenames]
+ @cookbook_version.resource_filenames = @cookbook[:resource_filenames]
+ @cookbook_version.provider_filenames = @cookbook[:provider_filenames]
+ @cookbook_version.root_filenames = @cookbook[:root_filenames]
+ @cookbook_version.metadata_filenames = @cookbook[:metadata_filenames]
+
+ # Used to test file-specificity related file lookups
+ @node = Chef::Node.new
+ @node.set[:platform] = "ubuntu"
+ @node.set[:platform_version] = "13.04"
+ @node.name("testing")
+ end
- it "should see a template using an array lookup with non-existant elements" do
- @cookbook_version.should have_template_for_node(@node, ["missing.txt", "test.erb"])
- end
+ it "should see a template" do
+ @cookbook_version.should have_template_for_node(@node, "test.erb")
+ end
- it "should see a file" do
- @cookbook_version.should have_cookbook_file_for_node(@node, "test.txt")
- end
+ it "should see a template using an array lookup" do
+ @cookbook_version.should have_template_for_node(@node, ["test.erb"])
+ end
- it "should see a file using an array lookup" do
- @cookbook_version.should have_cookbook_file_for_node(@node, ["test.txt"])
- end
+ it "should see a template using an array lookup with non-existant elements" do
+ @cookbook_version.should have_template_for_node(@node, ["missing.txt", "test.erb"])
+ end
- it "should see a file using an array lookup with non-existant elements" do
- @cookbook_version.should have_cookbook_file_for_node(@node, ["missing.txt", "test.txt"])
- end
+ it "should see a file" do
+ @cookbook_version.should have_cookbook_file_for_node(@node, "test.txt")
+ end
+
+ it "should see a file using an array lookup" do
+ @cookbook_version.should have_cookbook_file_for_node(@node, ["test.txt"])
+ end
+ it "should see a file using an array lookup with non-existant elements" do
+ @cookbook_version.should have_cookbook_file_for_node(@node, ["missing.txt", "test.txt"])
end
end