Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Allow relative paths for generator cookbook config #274

Merged
merged 1 commit into from
Dec 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/chef-dk/chef_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ChefRunner
attr_reader :run_list

def initialize(cookbook_path, run_list)
@cookbook_path = cookbook_path
@cookbook_path = File.expand_path(cookbook_path)
@run_list = run_list
@formatter = nil
@ohai = nil
Expand All @@ -39,7 +39,7 @@ def converge
message = "Could not find cookbook(s) to satisfy run list #{run_list.inspect} in #{cookbook_path}"
raise CookbookNotFound.new(message, e)
rescue => e
raise ChefConvergeError("Chef failed to converge: #{e}", e)
raise ChefConvergeError.new("Chef failed to converge: #{e}", e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be a test that had to be fixed from this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test added.

end

def run_context
Expand Down
26 changes: 26 additions & 0 deletions spec/unit/chef_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@
expect(test_state[:loaded_recipes]).to eq([ "recipe_one", "recipe_two" ])
expect(test_state[:converged_recipes]).to eq([ "recipe_one", "recipe_two" ])
end

context "when the embedded chef run fails" do

let(:embedded_runner) { instance_double("Chef::Runner") }

before do
allow(Chef::Runner).to receive(:new).and_return(embedded_runner)
allow(embedded_runner).to receive(:converge).and_raise("oops")
end

it "wraps the exception in a ChefConvergeError" do
expect { chef_runner.converge }.to raise_error(ChefDK::ChefConvergeError)
end

end

context "when cookbook_path is relative" do

let(:default_cookbook_path) { "~/heres_some_cookbooks" }

it "expands the path" do
expect(chef_runner.cookbook_path).to eq(File.expand_path(default_cookbook_path))
end

end

end