summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS.Cavallo <smcavallo@hotmail.com>2018-05-12 20:40:35 -0400
committerS.Cavallo <smcavallo@hotmail.com>2018-05-12 20:40:35 -0400
commitc19e2a3b714da60091134b264a3ca2373ae2c17b (patch)
treef089bd34ed600b3fbb620e7cf04a8dd8573ee26e
parent32e6d65f449af38fad8712366d2400c148f0ad94 (diff)
downloadchef-c19e2a3b714da60091134b264a3ca2373ae2c17b.tar.gz
chefspec style updates
move knife config test into unique tests - allows the default profile tests to test for null Signed-off-by: S.Cavallo <smcavallo@hotmail.com>
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb2
-rw-r--r--chef-config/spec/unit/workstation_config_loader_spec.rb21
2 files changed, 21 insertions, 2 deletions
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index b7b361316d..efc09de455 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -156,7 +156,7 @@ module ChefConfig
Config.chef_server_url = creds.fetch("chef_server_url") if creds.key?("chef_server_url")
Config.validation_client_name = creds.fetch("validation_client_name") if creds.key?("validation_client_name")
- Config.knife.merge!(Hash[creds.fetch('knife', {}).map{|k, v| [k.to_sym, v]}])
+ Config.knife.merge!(Hash[creds.fetch('knife', {}).map { |k, v| [k.to_sym, v] }])
extract_key(creds, "validation_key", :validation_key, :validation_key_contents)
extract_key(creds, "validator_key", :validation_key, :validation_key_contents)
diff --git a/chef-config/spec/unit/workstation_config_loader_spec.rb b/chef-config/spec/unit/workstation_config_loader_spec.rb
index f8c04bb724..8f1cde17e6 100644
--- a/chef-config/spec/unit/workstation_config_loader_spec.rb
+++ b/chef-config/spec/unit/workstation_config_loader_spec.rb
@@ -394,6 +394,25 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do
node_name = 'barney'
client_key = "barney_rubble.pem"
chef_server_url = "https://api.chef.io/organizations/bedrock"
+EOH
+ content
+ end
+
+ it "applies the expected config" do
+ expect { config_loader.load_credentials }.not_to raise_error
+ expect(ChefConfig::Config.chef_server_url).to eq("https://api.chef.io/organizations/bedrock")
+ expect(ChefConfig::Config.client_key.to_s).to eq("#{home}/.chef/barney_rubble.pem")
+ expect(ChefConfig::Config.profile.to_s).to eq("default")
+ end
+ end
+
+ context "and has a default profile with knife settings" do
+ let(:content) do
+ content = <<EOH
+[default]
+node_name = 'barney'
+client_key = "barney_rubble.pem"
+chef_server_url = "https://api.chef.io/organizations/bedrock"
knife = {
secret_file = "/home/barney/.chef/encrypted_data_bag_secret.pem"
}
@@ -403,7 +422,7 @@ EOH
content
end
- it "applies the expected config" do
+ it "applies the expected knife config" do
expect { config_loader.load_credentials }.not_to raise_error
expect(ChefConfig::Config.chef_server_url).to eq("https://api.chef.io/organizations/bedrock")
expect(ChefConfig::Config.client_key.to_s).to eq("#{home}/.chef/barney_rubble.pem")