Skip to content

Commit

Permalink
Merge pull request #193 from chef/mp/fix-missing-config-file
Browse files Browse the repository at this point in the history
Fix error that occurs when config file deleted.
  • Loading branch information
marcparadise authored Jun 5, 2018
2 parents 3fd1074 + e84acf7 commit 12f654f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/chef-run/lib/chef-run/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def location
end

def load
from_file(location)
if exist?
from_file(location)
end
end

def exist?
Expand Down
21 changes: 21 additions & 0 deletions components/chef-run/spec/unit/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,25 @@
expect(config.telemetry.dev).to eq(true)
end
end
describe "#load" do
before do
expect(subject).to receive(:exist?).and_return(exists)
end

context "when the config file exists" do
let(:exists) { true }
it "loads the file" do
expect(subject).to receive(:from_file)
subject.load
end
end

context "when the config file does not exist" do
let(:exists) { false }
it "does not try to load the file" do
expect(subject).to_not receive(:from_file)
subject.load
end
end
end
end

0 comments on commit 12f654f

Please sign in to comment.