spec/support/chef_server.rb in berkshelf-5.5.0 vs spec/support/chef_server.rb in berkshelf-5.6.0
- old
+ new
@@ -1,7 +1,7 @@
-require 'chef_zero/server'
-require 'json'
+require "chef_zero/server"
+require "json"
module Berkshelf::RSpec
module ChefServer
PORT = 4000
@@ -56,30 +56,30 @@
def chef_client(name, hash = {})
load_data(:clients, name, hash)
end
def chef_cookbook(name, hash = {})
- chef_server.load_data({ 'cookbooks' => { name => hash }})
+ chef_server.load_data({ "cookbooks" => { name => hash } })
end
def chef_cookbooks
- chef_server.data_store.list(['organizations', 'chef', 'cookbooks']).inject({}) do |hash, name|
- hash[name] = chef_server.data_store.list(['organizations', 'chef', 'cookbooks', name])
+ chef_server.data_store.list(%w{organizations chef cookbooks}).inject({}) do |hash, name|
+ hash[name] = chef_server.data_store.list(["organizations", "chef", "cookbooks", name])
hash
end
end
def chef_data_bag(name, hash = {})
- chef_server.load_data({ 'data' => { name => hash }})
+ chef_server.load_data({ "data" => { name => hash } })
end
def chef_environment(name, hash = {})
load_data(:environments, name, hash)
end
def chef_environment_locks(name)
- JSON.parse(chef_server.data_store.get(['organizations', 'chef', 'environments', name]))['cookbook_versions']
+ JSON.parse(chef_server.data_store.get(["organizations", "chef", "environments", name]))["cookbook_versions"]
rescue ChefZero::DataStore::DataNotFoundError
{}
end
def chef_node(name, hash = {})
@@ -90,10 +90,10 @@
load_data(:roles, name, hash)
end
private
- def load_data(key, name, hash)
- chef_server.load_data({ key.to_s => { name => JSON.generate(hash) }})
- end
+ def load_data(key, name, hash)
+ chef_server.load_data({ key.to_s => { name => JSON.generate(hash) } })
+ end
end
end