diff --git a/chef-dk.gemspec b/chef-dk.gemspec index aa4d5adf4..77fa22f17 100644 --- a/chef-dk.gemspec +++ b/chef-dk.gemspec @@ -46,7 +46,7 @@ Gem::Specification.new do |gem| gem.add_dependency "solve", "~> 2.0", ">= 2.0.1" - gem.add_dependency "cookbook-omnifetch", "~> 0.2" + gem.add_dependency "cookbook-omnifetch", "~> 0.2", ">= 0.2.2" gem.add_dependency "diff-lcs", "~> 1.0" gem.add_dependency "paint", "~> 1.0" diff --git a/lib/chef-dk/policyfile/cookbook_location_specification.rb b/lib/chef-dk/policyfile/cookbook_location_specification.rb index 3faea5c6a..45ca47986 100644 --- a/lib/chef-dk/policyfile/cookbook_location_specification.rb +++ b/lib/chef-dk/policyfile/cookbook_location_specification.rb @@ -60,6 +60,14 @@ def ==(other) other.source_options == source_options end + def to_s + # Note, this may appear in exceptions + s = "Cookbook '#{name}'" + s << " #{version_constraint}" + s << " #{source_options}" unless source_options.empty? + s + end + def mirrors_canonical_upstream? [:git, :github, :artifactserver].include?(source_type) end diff --git a/spec/unit/policyfile/cookbook_location_specification_spec.rb b/spec/unit/policyfile/cookbook_location_specification_spec.rb index 34358fe4f..b60f4a719 100644 --- a/spec/unit/policyfile/cookbook_location_specification_spec.rb +++ b/spec/unit/policyfile/cookbook_location_specification_spec.rb @@ -77,6 +77,11 @@ expect(cookbook_location_spec.source_options_for_lock).to eq(lock_data) end + it "converts to a readable string with all relevant info" do + expected_s = "Cookbook 'my_cookbook' >= 0.0.0" + expect(cookbook_location_spec.to_s).to eq(expected_s) + end + describe "fetching and querying a cookbook" do before do