diff options
author | Paul Berry <paul@puppetlabs.com> | 2011-02-25 14:56:58 -0800 |
---|---|---|
committer | Paul Berry <paul@puppetlabs.com> | 2011-02-25 14:56:58 -0800 |
commit | 23a510a321e47a98768dc47f95cfa0bd8c1a314c (patch) | |
tree | 96361304f3cae69ba9eef416a1977db88741dd7f /spec | |
parent | c57c508e938083115bbc00037901f652505288b0 (diff) | |
download | puppet-23a510a321e47a98768dc47f95cfa0bd8c1a314c.tar.gz puppet-23a510a321e47a98768dc47f95cfa0bd8c1a314c.tar.xz puppet-23a510a321e47a98768dc47f95cfa0bd8c1a314c.zip |
(#4914) Improved stubbing in mount/parsed_spec tests.
A few of the spec tests were attempting to stub
Puppet::Type::Mount#default_target so that it pointed to a temporary
file rather than /etc/fstab, but they were creating the stub after the
first call to default_target, so both /etc/fstab and the temporary
file were being read. This caused errors when running spec tests on
platforms where /etc/fstab is unreadable by non-privileged users.
Fixed the problem by moving the stub declaration earlier in the test.
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/provider/mount/parsed_spec.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb index 2a305b905..4d654fa72 100755 --- a/spec/unit/provider/mount/parsed_spec.rb +++ b/spec/unit/provider/mount/parsed_spec.rb @@ -220,6 +220,11 @@ FSTAB include ParsedMountTesting before :each do + # Note: we have to stub default_target before creating resources + # because it is used by Puppet::Type::Mount.new to populate the + # :target property. + @provider.stubs(:default_target).returns fake_fstab + @res_ghost = Puppet::Type::Mount.new(:name => '/ghost') # in no fake fstab @res_mounted = Puppet::Type::Mount.new(:name => '/') # in every fake fstab @res_unmounted = Puppet::Type::Mount.new(:name => '/boot') # in every fake fstab @@ -232,7 +237,6 @@ FSTAB end @provider.stubs(:mountcmd).returns File.read(fake_mountoutput) - @provider.stubs(:default_target).returns fake_fstab end it "should set :ensure to :unmounted if found in fstab but not mounted" do |