diff options
-rw-r--r-- | Rakefile | 8 | ||||
-rw-r--r-- | chef/lib/chef/knife.rb | 2 | ||||
-rw-r--r-- | chef/lib/chef/knife/cookbook_metadata.rb | 2 | ||||
-rw-r--r-- | cucumber.yml | 1 | ||||
-rw-r--r-- | features/cookbooks/metadata.feature | 6 | ||||
-rw-r--r-- | features/steps/cookbook_steps.rb | 18 |
6 files changed, 26 insertions, 11 deletions
@@ -355,6 +355,14 @@ namespace :features do t.profile = "cookbooks" end + namespace :cookbook do + + desc "Run cucumber tests for the cookbook metadata" + Cucumber::Rake::Task.new(:metadata) do |t| + t.profile = "cookbook_metadata" + end + end + desc "Run cucumber tests for the recipe language" Cucumber::Rake::Task.new(:language) do |t| t.profile = "language" diff --git a/chef/lib/chef/knife.rb b/chef/lib/chef/knife.rb index 5add3639ec..4933a5273b 100644 --- a/chef/lib/chef/knife.rb +++ b/chef/lib/chef/knife.rb @@ -91,7 +91,7 @@ class Chef puts klass_instance.opt_parser exit 1 end - klass_instance.name_args = (extra - cli_bits) || [] + klass_instance.name_args = extra.inject([]) { |c, i| cli_bits.include?(i) ? cli_bits.delete(i) : c << i; c } klass_instance.configure_chef klass_instance end diff --git a/chef/lib/chef/knife/cookbook_metadata.rb b/chef/lib/chef/knife/cookbook_metadata.rb index 3362c8ba04..b821b5d94b 100644 --- a/chef/lib/chef/knife/cookbook_metadata.rb +++ b/chef/lib/chef/knife/cookbook_metadata.rb @@ -56,7 +56,7 @@ class Chef def generate_metadata(cookbook) Chef::Log.info("Generating metadata for #{cookbook}") config[:cookbook_path].reverse.each do |path| - file = File.join(path, cookbook, 'metadata.rb') + file = File.expand_path(File.join(path, cookbook, 'metadata.rb')) if File.exists?(file) Chef::Log.info("Generating from #{file}") md = Chef::Cookbook::Metadata.new diff --git a/cucumber.yml b/cucumber.yml index 895eec907e..27e22105e2 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -45,6 +45,7 @@ client_run_interval: --tags client_run_interval --format pretty -r features/step recipe_inclusion: --tags recipe_inclusion --format pretty -r features/steps -r features/support features attribute_inclusion: --tags @attribute_inclusion --format pretty -r features/steps -r features/support features cookbooks: --tags @cookbooks --format pretty -r features/steps -r features/support features +cookbook_metadata: --tags @cookbook_metadata --format pretty -r features/steps -r features/support features provider_remote_directory: --tags @remote_directory --format pretty -r features/steps -r features/support features provider_git: --tags provider,git --format pretty -r features/steps -r features/support features provider_template: --tags template --format pretty -r features/steps -r features/support features diff --git a/features/cookbooks/metadata.feature b/features/cookbooks/metadata.feature index 658aff70ee..17be127b22 100644 --- a/features/cookbooks/metadata.feature +++ b/features/cookbooks/metadata.feature @@ -1,4 +1,4 @@ -@cookbooks +@cookbooks @cookbook_metadata Feature: Cookbook Metadata In order to understand cookbooks without evaluating them As an Administrator @@ -6,7 +6,7 @@ Feature: Cookbook Metadata Scenario: Generate metadata for all cookbooks Given a local cookbook repository - When I run the rake task to generate cookbook metadata + When I run the task to generate cookbook metadata Then the run should exit '0' And 'stdout' should have 'Generating metadata for metadata' And 'stdout' should have 'Generating metadata for execute_commands' @@ -14,7 +14,7 @@ Feature: Cookbook Metadata Scenario: Generate metadata for a specific cookbook Given a local cookbook repository - When I run the rake task to generate cookbook metadata for 'metadata' + When I run the task to generate cookbook metadata for 'metadata' Then the run should exit '0' And 'stdout' should have 'Generating metadata for metadata' And a file named 'cookbooks_dir/cookbooks/metadata/metadata.json' should exist diff --git a/features/steps/cookbook_steps.rb b/features/steps/cookbook_steps.rb index 521c4546da..790298ee02 100644 --- a/features/steps/cookbook_steps.rb +++ b/features/steps/cookbook_steps.rb @@ -37,15 +37,21 @@ Given /^a local cookbook named '(.+)'$/ do |cb| cleanup_dirs << "#{tmpdir}/cookbooks_dir" end -When /^I run the rake task to generate cookbook metadata for '(.+)'$/ do |cb| +When /^I run the task to generate cookbook metadata for '(.+)'$/ do |cb| self.cookbook = cb - When('I run the rake task to generate cookbook metadata') + When('I run the task to generate cookbook metadata') end -When /^I run the rake task to generate cookbook metadata$/ do - to_run = "rake metadata" - to_run += " COOKBOOK=#{cookbook}" if cookbook - Dir.chdir(File.join(tmpdir, 'cookbooks_dir')) do +When /^I run the task to generate cookbook metadata$/ do + knife_cmd = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "chef", "bin", "knife")) + to_run = "#{knife_cmd} cookbook metadata" + if cookbook + to_run += " #{cookbook}" + else + to_run += " -a" + end + to_run += " -o #{File.join(tmpdir, 'cookbooks_dir', 'cookbooks')}" + Dir.chdir(File.join(tmpdir, 'cookbooks_dir', 'cookbooks')) do self.status = Chef::Mixin::Command.popen4(to_run) do |p, i, o, e| self.stdout = o.gets(nil) self.stderr = o.gets(nil) |