diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2016-02-24 21:18:40 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2016-02-24 22:17:55 -0800 |
commit | 158178c3e039f3fcf0726fe3c7873bd80685f787 (patch) | |
tree | 58ef4f26f083b7bc053502b2be16d0b922f0c06c /spec/unit/application | |
parent | cbb0f567ba9fa669a43761c6e2452734fa9a3fd5 (diff) | |
download | chef-158178c3e039f3fcf0726fe3c7873bd80685f787.tar.gz |
Add test for solo.d
This commit refactors the spec to use shared examples
as the test for client.d and solo.d is the same.
knife.d is a little special so it cannot use this.
Diffstat (limited to 'spec/unit/application')
-rw-r--r-- | spec/unit/application/client_spec.rb | 54 | ||||
-rw-r--r-- | spec/unit/application/solo_spec.rb | 3 |
2 files changed, 5 insertions, 52 deletions
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb index f742d24e24..97a297ccb5 100644 --- a/spec/unit/application/client_spec.rb +++ b/spec/unit/application/client_spec.rb @@ -258,58 +258,8 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config end end - describe "client.d" do - before do - Chef::Config[:client_d_dir] = client_d_dir - end - - context "when client_d_dir is set to nil" do - let(:client_d_dir) { nil } - - it "does not raise an exception" do - expect { app.reconfigure }.not_to raise_error - end - end - - context "when client_d_dir is set to a directory with configuration" do - # We're not going to mock out globbing the directory. We want to - # make sure that we are correctly globbing. - let(:client_d_dir) { Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../data/client.d_00")) } - - it "loads the configuration in order" do - expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_return("foo 0") - expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_return("bar 0") - allow(app).to receive(:apply_config).with(anything(), Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_call_original.ordered - expect(app).to receive(:apply_config).with("foo 0", Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_call_original.ordered - expect(app).to receive(:apply_config).with("bar 0", Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_call_original.ordered - app.reconfigure - end - end - - context "when client_d_dir is set to a directory without configuration" do - let(:client_d_dir) { Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../data/client.d_01")) } - - # client.d_01 has a nested folder with a rb file that if - # executed, would raise an exception. If it is executed, - # it means we are loading configs that are deeply nested - # inside of client.d. For example, client.d/foo/bar.rb - # should not run, but client.d/foo.rb should. - it "does not raise an exception" do - expect { app.reconfigure }.not_to raise_error - end - end - - context "when client_d_dir is set to a directory containing a directory named foo.rb" do - # foo.rb as a directory should be ignored - let(:client_d_dir) { Chef::Util::PathHelper.cleanpath( - File.join(File.dirname(__FILE__), "../../data/client.d_02")) } - - it "does not raise an exception" do - expect { app.reconfigure }.not_to raise_error - end - end + it_behaves_like "an application that loads a dot d" do + let(:dot_d_config_name) { :client_d_dir } end end diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb index 4361a2cd33..85799d73db 100644 --- a/spec/unit/application/solo_spec.rb +++ b/spec/unit/application/solo_spec.rb @@ -164,4 +164,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config end end + it_behaves_like "an application that loads a dot d" do + let(:dot_d_config_name) { :solo_d_dir } + end end |