summaryrefslogtreecommitdiff
path: root/spec/unit/application/client_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/application/client_spec.rb')
-rw-r--r--spec/unit/application/client_spec.rb50
1 files changed, 38 insertions, 12 deletions
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 3f803f2033..0cd3cb3995 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -107,6 +107,7 @@ describe Chef::Application::Client, "reconfigure" do
shared_examples "sets the configuration" do |cli_arguments, expected_config|
describe cli_arguments do
before do
+ cli_arguments ||= ""
ARGV.replace(cli_arguments.split)
app.reconfigure
end
@@ -144,6 +145,36 @@ describe Chef::Application::Client, "reconfigure" do
end
end
+ describe "--[no]-fork" do
+ before do
+ Chef::Config[:interval] = nil # FIXME: we're overriding the before block setting this
+ end
+
+ context "by default" do
+ it_behaves_like "sets the configuration", "", client_fork: false
+ end
+
+ context "with --fork" do
+ it_behaves_like "sets the configuration", "--fork", client_fork: true
+ end
+
+ context "with --no-fork" do
+ it_behaves_like "sets the configuration", "--no-fork", client_fork: false
+ end
+
+ context "with an interval" do
+ it_behaves_like "sets the configuration", "--interval 1800", client_fork: true
+ end
+
+ context "with once" do
+ it_behaves_like "sets the configuration", "--once", client_fork: false
+ end
+
+ context "with daemonize", :unix_only do
+ it_behaves_like "sets the configuration", "--daemonize", client_fork: 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",
@@ -186,21 +217,16 @@ describe Chef::Application::Client, "reconfigure" do
Chef::Config[:splay] = nil
end
- context "when interval is given" do
- before do
- Chef::Config[:interval] = 600
- allow(ChefConfig).to receive(:windows?).and_return(false)
- end
-
- it "should terminate with message" do
- expect(Chef::Application).to receive(:fatal!).with(
-"Unforked chef-client interval runs are disabled in Chef 12.
+ it "should terminal with message when interval is given" do
+ Chef::Config[:interval] = 600
+ allow(ChefConfig).to receive(:windows?).and_return(false)
+ expect(Chef::Application).to receive(:fatal!).with(
+ "Unforked chef-client interval runs are disabled in Chef 12.
Configuration settings:
interval = 600 seconds
Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
- )
- app.reconfigure
- end
+ )
+ app.reconfigure
end
context "when interval is given on windows" do