spec/support/chef_api.rb in berkshelf-2.0.0.beta vs spec/support/chef_api.rb in berkshelf-2.0.0
- old
+ new
@@ -22,11 +22,12 @@
if version.nil?
ridley.cookbook.delete_all(name)
else
ridley.cookbook.delete(name, version)
end
- rescue Ridley::Errors::HTTPNotFound
+ rescue Ridley::Errors::HTTPNotFound,
+ Ridley::Errors::ResourceNotFound
true
end
def server_has_cookbook?(name, version = nil)
versions = ridley.cookbook.versions(name)
@@ -34,11 +35,12 @@
if version.nil?
!versions.empty?
else
!versions.find { |ver| ver == version }.nil?
end
- rescue Ridley::Errors::HTTPNotFound
+ rescue Ridley::Errors::HTTPNotFound,
+ Ridley::Errors::ResourceNotFound
false
end
def generate_cookbook(path, name, version, options = {})
path = Pathname.new(path)
@@ -65,15 +67,18 @@
files.each do |file|
FileUtils.touch(cookbook_path.join(file))
end
- metadata = <<-EOF
-name "#{name}"
-version "#{version}"
-EOF
+ metadata = [].tap do |a|
+ a << "name '#{name}'"
+ a << "version '#{version}'"
+ a << "license '#{options[:license]}'" if options[:license]
+ a << "" # ensure newline
+ end.join("\n")
+
if options[:dependencies]
options[:dependencies].each do |name, constraint|
metadata << "depends '#{name}', '#{constraint}'\n"
end
end
@@ -109,12 +114,12 @@
private
def ridley
@ridley ||= Ridley.new(
- server_url: Berkshelf::Chef::Config[:chef_server_url],
- client_name: Berkshelf::Chef::Config[:node_name],
- client_key: Berkshelf::Chef::Config[:client_key],
+ server_url: Berkshelf.chef_config[:chef_server_url],
+ client_name: Berkshelf.chef_config[:node_name],
+ client_key: Berkshelf.chef_config[:client_key],
ssl: { verify: false }
)
end
end
end