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

Commit

Permalink
Allow cookbooks to be defined with no source option in DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsdeleo committed Mar 26, 2015
1 parent 1072cf8 commit 2dc31c6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/chef-dk/policyfile/cookbook_location_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def valid?

def errors
error_messages = []
if installer.nil?
if source_options_invalid?
error_messages << "Cookbook `#{name}' has invalid source options `#{source_options.inspect}'"
end
error_messages
Expand Down Expand Up @@ -124,6 +124,10 @@ def source_options_for_lock
installer.lock_data
end

def source_options_invalid?
!source_options.empty? && installer.nil?
end

end
end
end
16 changes: 16 additions & 0 deletions spec/unit/policyfile_evaluation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@

end

context "with an added cookbook with no options" do

let(:policyfile_rb) do
<<-EOH
run_list "foo", "bar"
cookbook "baz"
EOH
end

it "adds the cookbook to the list of location specs" do
expect(policyfile.errors).to eq([])
expected_cb_spec = ChefDK::Policyfile::CookbookLocationSpecification.new("baz", ">= 0.0.0", {}, storage_config)
expect(policyfile.cookbook_location_specs).to eq("baz" => expected_cb_spec)
end
end

end

context "with the default source set to a chef server" do
Expand Down

0 comments on commit 2dc31c6

Please sign in to comment.