summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2008-02-18 11:48:11 -0600
committerRick Bradley <rick@rickbradley.com>2008-02-18 11:48:11 -0600
commitbecafab0aee2ea5f07622a1e74bd5393ff44464d (patch)
tree02f76a4ae49368905a4305f2e5e40edca5554d32
parent034336bb1d9d8a3d3220aa62eb18c796f7982f53 (diff)
downloadpuppet-becafab0aee2ea5f07622a1e74bd5393ff44464d.tar.gz
puppet-becafab0aee2ea5f07622a1e74bd5393ff44464d.tar.xz
puppet-becafab0aee2ea5f07622a1e74bd5393ff44464d.zip
converting mount type specs from setup/teardown to before/after
-rwxr-xr-xspec/unit/ral/types/mount.rb185
1 files changed, 91 insertions, 94 deletions
diff --git a/spec/unit/ral/types/mount.rb b/spec/unit/ral/types/mount.rb
index 7d01022b5..9247601e6 100755
--- a/spec/unit/ral/types/mount.rb
+++ b/spec/unit/ral/types/mount.rb
@@ -57,8 +57,8 @@ describe Puppet::Type::Mount::Ensure, "when validating values" do
after { Puppet::Type::Mount.clear }
end
-module MountEvaluationTesting
- def setup
+describe Puppet::Type::Mount::Ensure do
+ before :each do
@provider = stub 'provider', :class => Puppet::Type::Mount.defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
Puppet::Type::Mount.defaultprovider.stubs(:new).returns(@provider)
@mount = Puppet::Type::Mount.create(:name => "yay", :check => :ensure)
@@ -66,6 +66,10 @@ module MountEvaluationTesting
@ensure = @mount.property(:ensure)
end
+ after :each do
+ Puppet::Type::Mount.clear
+ end
+
def mount_stub(params)
Puppet::Type::Mount.validproperties.each do |prop|
unless params[prop]
@@ -79,117 +83,110 @@ module MountEvaluationTesting
end
end
- def teardown
- Puppet::Type::Mount.clear
- end
-end
-
-describe Puppet::Type::Mount::Ensure, "when retrieving its current state" do
- include MountEvaluationTesting
+ describe Puppet::Type::Mount::Ensure, "when retrieving its current state" do
- it "should return the provider's value if it is :absent" do
- @provider.expects(:ensure).returns(:absent)
- @ensure.retrieve.should == :absent
- end
+ it "should return the provider's value if it is :absent" do
+ @provider.expects(:ensure).returns(:absent)
+ @ensure.retrieve.should == :absent
+ end
- it "should return :mounted if the provider indicates it is mounted and the value is not :absent" do
- @provider.expects(:ensure).returns(:present)
- @provider.expects(:mounted?).returns(true)
- @ensure.retrieve.should == :mounted
- end
+ it "should return :mounted if the provider indicates it is mounted and the value is not :absent" do
+ @provider.expects(:ensure).returns(:present)
+ @provider.expects(:mounted?).returns(true)
+ @ensure.retrieve.should == :mounted
+ end
- it "should return :present if the provider indicates it is not mounted and the value is not :absent" do
- @provider.expects(:ensure).returns(:present)
- @provider.expects(:mounted?).returns(false)
- @ensure.retrieve.should == :present
+ it "should return :present if the provider indicates it is not mounted and the value is not :absent" do
+ @provider.expects(:ensure).returns(:present)
+ @provider.expects(:mounted?).returns(false)
+ @ensure.retrieve.should == :present
+ end
end
-end
-describe Puppet::Type::Mount::Ensure, "when changing the host" do
- include MountEvaluationTesting
+ describe Puppet::Type::Mount::Ensure, "when changing the host" do
- it "should destroy itself if it should be absent" do
- @provider.stubs(:mounted?).returns(false)
- @provider.expects(:destroy)
- @ensure.should = :absent
- @ensure.sync
- end
+ it "should destroy itself if it should be absent" do
+ @provider.stubs(:mounted?).returns(false)
+ @provider.expects(:destroy)
+ @ensure.should = :absent
+ @ensure.sync
+ end
- it "should unmount itself before destroying if it is mounted and should be absent" do
- @provider.expects(:mounted?).returns(true)
- @provider.expects(:unmount)
- @provider.expects(:destroy)
- @ensure.should = :absent
- @ensure.sync
- end
+ it "should unmount itself before destroying if it is mounted and should be absent" do
+ @provider.expects(:mounted?).returns(true)
+ @provider.expects(:unmount)
+ @provider.expects(:destroy)
+ @ensure.should = :absent
+ @ensure.sync
+ end
- it "should create itself if it is absent and should be present" do
- @provider.stubs(:mounted?).returns(false)
- @provider.expects(:create)
- @ensure.should = :present
- @ensure.sync
- end
+ it "should create itself if it is absent and should be present" do
+ @provider.stubs(:mounted?).returns(false)
+ @provider.expects(:create)
+ @ensure.should = :present
+ @ensure.sync
+ end
- it "should unmount itself if it is mounted and should be present" do
- @provider.stubs(:mounted?).returns(true)
+ it "should unmount itself if it is mounted and should be present" do
+ @provider.stubs(:mounted?).returns(true)
- # The interface here is just too much work to test right now.
- @ensure.stubs(:syncothers)
- @provider.expects(:unmount)
- @ensure.should = :present
- @ensure.sync
- end
+ # The interface here is just too much work to test right now.
+ @ensure.stubs(:syncothers)
+ @provider.expects(:unmount)
+ @ensure.should = :present
+ @ensure.sync
+ end
- it "should create and mount itself if it does not exist and should be mounted" do
- @provider.stubs(:ensure).returns(:absent)
- @provider.stubs(:mounted?).returns(false)
- @provider.expects(:create)
- @ensure.stubs(:syncothers)
- @provider.expects(:mount)
- @ensure.should = :mounted
- @ensure.sync
- end
+ it "should create and mount itself if it does not exist and should be mounted" do
+ @provider.stubs(:ensure).returns(:absent)
+ @provider.stubs(:mounted?).returns(false)
+ @provider.expects(:create)
+ @ensure.stubs(:syncothers)
+ @provider.expects(:mount)
+ @ensure.should = :mounted
+ @ensure.sync
+ end
- it "should mount itself if it is present and should be mounted" do
- @provider.stubs(:ensure).returns(:present)
- @provider.stubs(:mounted?).returns(false)
- @ensure.stubs(:syncothers)
- @provider.expects(:mount)
- @ensure.should = :mounted
- @ensure.sync
- end
+ it "should mount itself if it is present and should be mounted" do
+ @provider.stubs(:ensure).returns(:present)
+ @provider.stubs(:mounted?).returns(false)
+ @ensure.stubs(:syncothers)
+ @provider.expects(:mount)
+ @ensure.should = :mounted
+ @ensure.sync
+ end
- it "should create but not mount itself if it is absent and mounted and should be mounted" do
- @provider.stubs(:ensure).returns(:absent)
- @provider.stubs(:mounted?).returns(true)
- @ensure.stubs(:syncothers)
- @provider.expects(:create)
- @ensure.should = :mounted
- @ensure.sync
+ it "should create but not mount itself if it is absent and mounted and should be mounted" do
+ @provider.stubs(:ensure).returns(:absent)
+ @provider.stubs(:mounted?).returns(true)
+ @ensure.stubs(:syncothers)
+ @provider.expects(:create)
+ @ensure.should = :mounted
+ @ensure.sync
+ end
end
-end
-describe Puppet::Type::Mount, "when responding to events" do
- include MountEvaluationTesting
+ describe Puppet::Type::Mount, "when responding to events" do
- it "should remount if it is currently mounted" do
- @provider.expects(:mounted?).returns(true)
- @provider.expects(:remount)
+ it "should remount if it is currently mounted" do
+ @provider.expects(:mounted?).returns(true)
+ @provider.expects(:remount)
- @mount.refresh
- end
+ @mount.refresh
+ end
- it "should not remount if it is not currently mounted" do
- @provider.expects(:mounted?).returns(false)
- @provider.expects(:remount).never
+ it "should not remount if it is not currently mounted" do
+ @provider.expects(:mounted?).returns(false)
+ @provider.expects(:remount).never
- @mount.refresh
- end
+ @mount.refresh
+ end
- it "should not remount swap filesystems" do
- @mount[:fstype] = "swap"
- @provider.expects(:remount).never
+ it "should not remount swap filesystems" do
+ @mount[:fstype] = "swap"
+ @provider.expects(:remount).never
- @mount.refresh
+ @mount.refresh
+ end
end
-end
+end \ No newline at end of file