pidlock 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pidlock.rb +6 -0
- data/spec/lib/pidlock_spec.rb +13 -0
- metadata +1 -1
data/lib/pidlock.rb
CHANGED
data/spec/lib/pidlock_spec.rb
CHANGED
@@ -86,5 +86,18 @@ describe Pidlock do
|
|
86
86
|
pidlock.logger = logger2
|
87
87
|
pidlock.lock
|
88
88
|
end
|
89
|
+
it "should close and remove the file if unlocked" do
|
90
|
+
@file.should_receive(:gets).and_return('667')
|
91
|
+
ps = stub("ProcTableStruct", :comm => 'test')
|
92
|
+
::Sys::ProcTable.should_receive(:ps).with(667).and_return(nil)
|
93
|
+
logger.should_receive(:warn).with('WARNING: resetting stale lockfile')
|
94
|
+
@file.should_receive(:rewind)
|
95
|
+
@file.should_receive(:write).with(666)
|
96
|
+
lock = Pidlock.new('my.pid')
|
97
|
+
lock.lock
|
98
|
+
FileUtils.should_receive(:rm_f).with("/var/run/my.pid").and_return(true)
|
99
|
+
@file.should_receive(:close)
|
100
|
+
lock.unlock
|
101
|
+
end
|
89
102
|
end
|
90
103
|
end
|