Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error that occurs when config file deleted. #193

Merged
merged 1 commit into from
Jun 5, 2018
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: 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