summaryrefslogtreecommitdiffstats
path: root/spec/unit/agent
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/agent')
-rwxr-xr-xspec/unit/agent/locker_spec.rb130
1 files changed, 65 insertions, 65 deletions
diff --git a/spec/unit/agent/locker_spec.rb b/spec/unit/agent/locker_spec.rb
index 1477c824e..ad54c765a 100755
--- a/spec/unit/agent/locker_spec.rb
+++ b/spec/unit/agent/locker_spec.rb
@@ -5,96 +5,96 @@ require 'puppet/agent'
require 'puppet/agent/locker'
class LockerTester
- include Puppet::Agent::Locker
+ include Puppet::Agent::Locker
end
describe Puppet::Agent::Locker do
- before do
- @locker = LockerTester.new
- @locker.stubs(:lockfile_path).returns "/my/lock"
- end
+ before do
+ @locker = LockerTester.new
+ @locker.stubs(:lockfile_path).returns "/my/lock"
+ end
- it "should use a Pidlock instance as its lockfile" do
- @locker.lockfile.should be_instance_of(Puppet::Util::Pidlock)
- end
+ it "should use a Pidlock instance as its lockfile" do
+ @locker.lockfile.should be_instance_of(Puppet::Util::Pidlock)
+ end
- it "should use 'lockfile_path' to determine its lockfile path" do
- @locker.expects(:lockfile_path).returns "/my/lock"
- lock = Puppet::Util::Pidlock.new("/my/lock")
- Puppet::Util::Pidlock.expects(:new).with("/my/lock").returns lock
+ it "should use 'lockfile_path' to determine its lockfile path" do
+ @locker.expects(:lockfile_path).returns "/my/lock"
+ lock = Puppet::Util::Pidlock.new("/my/lock")
+ Puppet::Util::Pidlock.expects(:new).with("/my/lock").returns lock
- @locker.lockfile
- end
+ @locker.lockfile
+ end
- it "should reuse the same lock file each time" do
- @locker.lockfile.should equal(@locker.lockfile)
- end
+ it "should reuse the same lock file each time" do
+ @locker.lockfile.should equal(@locker.lockfile)
+ end
- it "should use the lock file to anonymously lock the process when disabled" do
- @locker.lockfile.expects(:lock).with(:anonymous => true)
+ it "should use the lock file to anonymously lock the process when disabled" do
+ @locker.lockfile.expects(:lock).with(:anonymous => true)
- @locker.disable
- end
+ @locker.disable
+ end
- it "should use the lock file to anonymously unlock the process when enabled" do
- @locker.lockfile.expects(:unlock).with(:anonymous => true)
+ it "should use the lock file to anonymously unlock the process when enabled" do
+ @locker.lockfile.expects(:unlock).with(:anonymous => true)
- @locker.enable
- end
+ @locker.enable
+ end
- it "should have a method that yields when a lock is attained" do
- @locker.lockfile.expects(:lock).returns true
+ it "should have a method that yields when a lock is attained" do
+ @locker.lockfile.expects(:lock).returns true
- yielded = false
- @locker.lock do
- yielded = true
- end
- yielded.should be_true
+ yielded = false
+ @locker.lock do
+ yielded = true
end
+ yielded.should be_true
+ end
- it "should return true when the lock method successfully locked" do
- @locker.lockfile.expects(:lock).returns true
+ it "should return true when the lock method successfully locked" do
+ @locker.lockfile.expects(:lock).returns true
- @locker.lock {}.should be_true
- end
+ @locker.lock {}.should be_true
+ end
- it "should return true when the lock method does not receive the lock" do
- @locker.lockfile.expects(:lock).returns false
+ it "should return true when the lock method does not receive the lock" do
+ @locker.lockfile.expects(:lock).returns false
- @locker.lock {}.should be_false
- end
+ @locker.lock {}.should be_false
+ end
- it "should not yield when the lock method does not receive the lock" do
- @locker.lockfile.expects(:lock).returns false
+ it "should not yield when the lock method does not receive the lock" do
+ @locker.lockfile.expects(:lock).returns false
- yielded = false
- @locker.lock { yielded = true }
- yielded.should be_false
- end
+ yielded = false
+ @locker.lock { yielded = true }
+ yielded.should be_false
+ end
- it "should not unlock when a lock was not received" do
- @locker.lockfile.expects(:lock).returns false
- @locker.lockfile.expects(:unlock).never
+ it "should not unlock when a lock was not received" do
+ @locker.lockfile.expects(:lock).returns false
+ @locker.lockfile.expects(:unlock).never
- @locker.lock {}
- end
+ @locker.lock {}
+ end
- it "should unlock after yielding upon obtaining a lock" do
- @locker.lockfile.stubs(:lock).returns true
- @locker.lockfile.expects(:unlock)
+ it "should unlock after yielding upon obtaining a lock" do
+ @locker.lockfile.stubs(:lock).returns true
+ @locker.lockfile.expects(:unlock)
- @locker.lock {}
- end
+ @locker.lock {}
+ end
- it "should unlock after yielding upon obtaining a lock, even if the block throws an exception" do
- @locker.lockfile.stubs(:lock).returns true
- @locker.lockfile.expects(:unlock)
+ it "should unlock after yielding upon obtaining a lock, even if the block throws an exception" do
+ @locker.lockfile.stubs(:lock).returns true
+ @locker.lockfile.expects(:unlock)
- lambda { @locker.lock { raise "foo" } }.should raise_error(RuntimeError)
- end
+ lambda { @locker.lock { raise "foo" } }.should raise_error(RuntimeError)
+ end
- it "should be considered running if the lockfile is locked" do
- @locker.lockfile.expects(:locked?).returns true
- @locker.should be_running
- end
+ it "should be considered running if the lockfile is locked" do
+ @locker.lockfile.expects(:locked?).returns true
+ @locker.should be_running
+ end
end