summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2016-06-21 16:04:01 -0700
committerNoah Kantrowitz <noah@coderanger.net>2016-06-21 16:07:59 -0700
commit267cd39a17454a17cce7eeef8aea292aec4647fc (patch)
tree10aa44ef2572c5e4786992314be1dc55b52becc7 /spec
parent8693be1d64b06b93fb357ac96588b17a6ea64579 (diff)
downloadchef-267cd39a17454a17cce7eeef8aea292aec4647fc.tar.gz
First pass on --config-option handling.
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/application/client_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 6765ca93ae..30fc58b84c 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -74,6 +74,8 @@ describe Chef::Application::Client, "reconfigure" do
end
before do
+ Chef::Config.reset
+
allow(Kernel).to receive(:trap).and_return(:ok)
allow(::File).to receive(:read).and_call_original
allow(::File).to receive(:read).with(Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_return("")
@@ -141,6 +143,39 @@ describe Chef::Application::Client, "reconfigure" do
:daemonize => true
end
end
+
+ describe "--config-option" do
+ context "with a single value" do
+ it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example",
+ :chef_server_url => "http://example"
+ end
+
+ context "with two values" do
+ it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example --config-option policy_name=web",
+ :chef_server_url => "http://example", :policy_name => "web"
+ end
+
+ context "with a boolean value" do
+ it_behaves_like "sets the configuration", "--config-option minimal_ohai=true",
+ :minimal_ohai => true
+ end
+
+ context "with an empty value" do
+ it "should terminate with message" do
+ expect(Chef::Application).to receive(:fatal!).with('Unparsable config option ""').and_raise("so ded")
+ ARGV.replace(["--config-option", ""])
+ expect { app.reconfigure }.to raise_error "so ded"
+ end
+ end
+
+ context "with an invalid value" do
+ it "should terminate with message" do
+ expect(Chef::Application).to receive(:fatal!).with('Unparsable config option "asdf"').and_raise("so ded")
+ ARGV.replace(["--config-option", "asdf"])
+ expect { app.reconfigure }.to raise_error "so ded"
+ end
+ end
+ end
end
describe "when configured to not fork the client process" do