summaryrefslogtreecommitdiff
path: root/spec/integration/knife/config_use_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/integration/knife/config_use_spec.rb')
-rw-r--r--spec/integration/knife/config_use_spec.rb50
1 files changed, 49 insertions, 1 deletions
diff --git a/spec/integration/knife/config_use_spec.rb b/spec/integration/knife/config_use_spec.rb
index 41d575669c..0431729b25 100644
--- a/spec/integration/knife/config_use_spec.rb
+++ b/spec/integration/knife/config_use_spec.rb
@@ -45,7 +45,7 @@ describe "knife config use", :workstation do
ChefConfig::PathHelper.per_tool_home_environment = "KNIFE_HOME"
# Clear these out because they are cached permanently.
ChefConfig::PathHelper.class_exec { remove_class_variable(:@@home_dir) }
- Chef::Knife::ConfigUseProfile.reset_config_loader!
+ Chef::Knife::ConfigUse.reset_config_loader!
begin
ex.run
ensure
@@ -67,6 +67,54 @@ describe "knife config use", :workstation do
ENV["HOME"] = path_to(".")
end
+ context "with no argument" do
+ context "with no configuration" do
+ it { is_expected.to eq "default\n" }
+ end
+
+ context "with --profile" do
+ let(:cmd_args) { %w{--profile production} }
+ it { is_expected.to eq "production\n" }
+ end
+
+ context "with an environment variable" do
+ around do |ex|
+ old_chef_profile = ENV["CHEF_PROFILE"]
+ begin
+ ENV["CHEF_PROFILE"] = "staging"
+ ex.run
+ ensure
+ ENV["CHEF_PROFILE"] = old_chef_profile
+ end
+ end
+
+ it { is_expected.to eq "staging\n" }
+ end
+
+ context "with a context file" do
+ before { file(".chef/context", "development\n") }
+ it { is_expected.to eq "development\n" }
+ end
+
+ context "with a context file under $CHEF_HOME" do
+ before do
+ file("chefhome/.chef/context", "other\n")
+ ENV["CHEF_HOME"] = path_to("chefhome")
+ end
+
+ it { is_expected.to eq "other\n" }
+ end
+
+ context "with a context file under $KNIFE_HOME" do
+ before do
+ file("knifehome/.chef/context", "other\n")
+ ENV["KNIFE_HOME"] = path_to("knifehome")
+ end
+
+ it { is_expected.to eq "other\n" }
+ end
+ end
+
context "with an argument" do
let(:cmd_args) { %w{production} }
before { file(".chef/credentials", <<~EOH) }