Skip to content

Commit f6c6fac

Browse files
committed
(PUP-11022) Allow Dir.entries
Newer facter versions call Dir.entries during fact resolution/provider loading, so call the original method by default. This fixes errors of the form: #<Dir (class)> received :entries with unexpected arguments expected: ("tmp") got: ("/Users/josh/.facter/facts.d")
1 parent 9b390bc commit f6c6fac

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

spec/unit/provider/service/init_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
allow(provider_class).to receive(:defpath).and_return('tmp')
8484

8585
@services = ['one', 'two', 'three', 'four', 'umountfs']
86+
allow(Dir).to receive(:entries).and_call_original
8687
allow(Dir).to receive(:entries).with('tmp').and_return(@services)
8788
expect(FileTest).to receive(:directory?).with('tmp').and_return(true)
8889
allow(FileTest).to receive(:executable?).and_return(true)

spec/unit/provider/service/openwrt_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
allow(File).to receive(:directory?).with('/etc/init.d').and_return(true)
3333

3434
allow(Puppet::FileSystem).to receive(:exist?).with('/etc/init.d/myservice').and_return(true)
35+
allow(FileTest).to receive(:file?).and_call_original
3536
allow(FileTest).to receive(:file?).with('/etc/init.d/myservice').and_return(true)
3637
allow(FileTest).to receive(:executable?).with('/etc/init.d/myservice').and_return(true)
3738
end
@@ -47,7 +48,8 @@
4748
let(:services) {['dnsmasq', 'dropbear', 'firewall', 'led', 'puppet', 'uhttpd' ]}
4849

4950
before :each do
50-
allow(Dir).to receive(:entries).and_return(services)
51+
allow(Dir).to receive(:entries).and_call_original
52+
allow(Dir).to receive(:entries).with('/etc/init.d').and_return(services)
5153
allow(FileTest).to receive(:directory?).and_return(true)
5254
allow(FileTest).to receive(:executable?).and_return(true)
5355
end

0 commit comments

Comments
 (0)