diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-21 11:54:04 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-21 13:53:29 -0700 |
commit | aa2241ab17bc131c80f358f87006099fb108fb04 (patch) | |
tree | 2e827cb0b52f11ea2a9805c7439894b2c1d558e3 /spec/unit | |
parent | a3f7e9cd52e8901cbfc5dfa3d93c032dec2ddb7e (diff) | |
download | chef-aa2241ab17bc131c80f358f87006099fb108fb04.tar.gz |
allow use_inline_resources for core chef providers
* removes the DSL from InlineResources class
* ActionClass is now responsible for mixing the DSL into
action classes
* apt_update provider converted over to use new syntax
- does not need to mixin DeclareResource DSL
- declares use_inline_resources
- uses declare_resource instead of build_resource
- converts def action_stuff to action :stuff
- uses an execute resource instead of shell_out!
- does not need the converge_by to update the action
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/lwrp_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/apt_update_spec.rb | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 6eba001af4..6574a91f13 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -754,7 +754,7 @@ describe "LWRP" do it "lets you extend the recipe DSL" do expect(Chef::Recipe).to receive(:include).with(MyAwesomeDSLExensionClass) - expect(Chef::Provider::InlineResources).to receive(:include).with(MyAwesomeDSLExensionClass) + expect(Chef::Resource::ActionClass).to receive(:include).with(MyAwesomeDSLExensionClass) Chef::DSL::Recipe.send(:include, MyAwesomeDSLExensionClass) end diff --git a/spec/unit/provider/apt_update_spec.rb b/spec/unit/provider/apt_update_spec.rb index b72f7d9a76..3e3e6ba07a 100644 --- a/spec/unit/provider/apt_update_spec.rb +++ b/spec/unit/provider/apt_update_spec.rb @@ -44,19 +44,19 @@ describe Chef::Provider::AptUpdate do context "when the apt config directory does not exist" do before do FileUtils.rmdir config_dir - expect(File.exist?(config_dir)).to be_falsey - allow(provider).to receive(:shell_out!).with("apt-get -q update") + expect(File.exist?(config_dir)).to be false + allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything()) end it "should create the directory" do provider.run_action(:update) - expect(File.exist?(config_dir)).to be_truthy - expect(File.directory?(config_dir)).to be_truthy + expect(File.exist?(config_dir)).to be true + expect(File.directory?(config_dir)).to be true end it "should create the config file" do provider.run_action(:update) - expect(File.exist?(config_file)).to be_truthy + expect(File.exist?(config_file)).to be true expect(File.read(config_file)).to match(/^APT::Update.*#{stamp_dir}/) end end @@ -64,7 +64,7 @@ describe Chef::Provider::AptUpdate do describe "#action_update" do it "should update the apt cache" do provider.load_current_resource - expect(provider).to receive(:shell_out!).with("apt-get -q update").and_return(double) + expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything()) provider.run_action(:update) expect(new_resource).to be_updated_by_last_action end @@ -78,14 +78,14 @@ describe Chef::Provider::AptUpdate do it "should run if the time stamp is old" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 86_500) - expect(provider).to receive(:shell_out!).with("apt-get -q update") + expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything()) provider.run_action(:periodic) expect(new_resource).to be_updated_by_last_action end it "should not run if the time stamp is new" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now) - expect(provider).to_not receive(:shell_out!).with("apt-get -q update") + expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out!).with("apt-get -q update", anything()) provider.run_action(:periodic) expect(new_resource).to_not be_updated_by_last_action end @@ -97,14 +97,14 @@ describe Chef::Provider::AptUpdate do it "should run if the time stamp is old" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 500) - expect(provider).to receive(:shell_out!).with("apt-get -q update") + expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).with("apt-get -q update", anything()) provider.run_action(:periodic) expect(new_resource).to be_updated_by_last_action end it "should not run if the time stamp is new" do expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 300) - expect(provider).to_not receive(:shell_out!).with("apt-get -q update") + expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out!).with("apt-get -q update", anything()) provider.run_action(:periodic) expect(new_resource).to_not be_updated_by_last_action end |