summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-04-28 11:48:55 -0700
committerTim Smith <tsmith@chef.io>2017-05-12 09:29:33 -0700
commitca63f97a0e750d4256cd57106e339686f8631dff (patch)
treec0e97f8199bfbbb25978e877af657c7a78bf9f69 /spec
parent3d6fcbd0870da39117f45662e367b36491237c3b (diff)
downloadchef-ca63f97a0e750d4256cd57106e339686f8631dff.tar.gz
Wire up provider/resource and use constants so we can test
Also allow the pin priority to be an integer since there's no reason that needs to be a string Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/apt_preference_spec.rb39
1 files changed, 25 insertions, 14 deletions
diff --git a/spec/unit/provider/apt_preference_spec.rb b/spec/unit/provider/apt_preference_spec.rb
index e841520014..3b529c81b9 100644
--- a/spec/unit/provider/apt_preference_spec.rb
+++ b/spec/unit/provider/apt_preference_spec.rb
@@ -21,6 +21,14 @@ require "spec_helper"
describe Chef::Provider::AptPreference do
let(:new_resource) { Chef::Resource::AptPreference.new("libmysqlclient16") }
+ let(:pref_dir) { Dir.mktmpdir("apt_pref_d") }
+
+ before do
+ stub_const("Chef::Provider::AptPreference::APT_PREFERENCE_DIR", pref_dir)
+ new_resource.pin = '1.0.1'
+ new_resource.pin_priority 1001
+ end
+
let(:provider) do
node = Chef::Node.new
events = Chef::EventDispatch::Dispatcher.new
@@ -32,22 +40,25 @@ describe Chef::Provider::AptPreference do
expect(provider).to respond_to(:load_current_resource)
end
- it "creates apt preferences directory if it does not exist" do
- provider.run_action(:update)
- expect(new_resource).to be_updated_by_last_action
- expect(File.exist?('/etc/apt/preferences.d')).to be true
- expect(File.directory?('/etc/apt/preferences.d')).to be true
- end
+ context "when the preferences.d directory does not exist" do
+ before do
+ FileUtils.rmdir pref_dir
+ expect(File.exist?(pref_dir)).to be false
+ end
- it "cleans up legacy non-sanitized name files" do
- # something
- end
+ it "should create the preferences.d directory" do
+ provider.run_action(:add)
+ expect(new_resource).to be_updated_by_last_action
+ expect(File.exist?(pref_dir)).to be true
+ expect(File.directory?(pref_dir)).to be true
+ end
- it "creates an apt .pref file" do
- # something
- end
+ it "creates an apt .pref file" do
+ # something
+ end
- it "creates an apt .pref file with a sanitized filename" do
- # something
+ it "creates an apt .pref file with a sanitized filename" do
+ # something
+ end
end
end