aboutsummaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorGabriel Nagy <gabrielnagy@me.com>2020-05-06 15:21:55 +0300
committerGitHub <noreply@github.com>2020-05-06 15:21:55 +0300
commit575c45082d48624ab8ed952b01c17302c0e4e1ef (patch)
treed4fd1507999a0d61b2edbc89f5381048470afb1b /spec/unit
parentc5367aa3508b49ccb19ede20967ecfff8fe6e124 (diff)
parent196dea8289d126aaf9a011a15b348fde0d5159d5 (diff)
downloadpuppet-cron_core-575c45082d48624ab8ed952b01c17302c0e4e1ef.tar.gz
puppet-cron_core-575c45082d48624ab8ed952b01c17302c0e4e1ef.tar.bz2
Merge pull request #12 from ekohl/hidden-files
(MODULES-8603) Ignore .keep_* files
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/provider/cron/crontab_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/unit/provider/cron/crontab_spec.rb b/spec/unit/provider/cron/crontab_spec.rb
index 031b3ae..796a4c2 100644
--- a/spec/unit/provider/cron/crontab_spec.rb
+++ b/spec/unit/provider/cron/crontab_spec.rb
@@ -202,4 +202,43 @@ describe Puppet::Type.type(:cron).provider(:crontab) do
end
end
end
+
+ context '#enumerate_crontabs' do
+ before(:each) do
+ File.expects(:readable?).with(subject.crontab_dir).returns(true)
+ Dir.expects(:foreach).with(subject.crontab_dir).multiple_yields(*files)
+ end
+
+ context 'only a hidden file' do
+ let(:files) { ['.keep_cronbase-0'] }
+
+ before(:each) do
+ files.each do |filename|
+ path = File.join(subject.crontab_dir, filename)
+ File.expects(:file?).with(path).returns(true)
+ File.expects(:writable?).with(path).returns(true)
+ end
+ end
+
+ it 'ignores .keep_* files' do
+ expect { |b| described_class.enumerate_crontabs(&b) }.not_to yield_control
+ end
+ end
+
+ context 'multiple files' do
+ let(:files) { ['myuser', '.keep_cronbase-0'] }
+
+ before(:each) do
+ files.each do |filename|
+ path = File.join(subject.crontab_dir, filename)
+ File.expects(:file?).with(path).returns(true)
+ File.expects(:writable?).with(path).returns(true)
+ end
+ end
+
+ it 'ignores .keep_* files' do
+ expect { |b| described_class.enumerate_crontabs(&b) }.to yield_control.once
+ end
+ end
+ end
end