summaryrefslogtreecommitdiff
path: root/spec/ruby/shared/process/fork.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/shared/process/fork.rb')
-rw-r--r--spec/ruby/shared/process/fork.rb33
1 files changed, 18 insertions, 15 deletions
diff --git a/spec/ruby/shared/process/fork.rb b/spec/ruby/shared/process/fork.rb
index 8dbb3d0da4..6c7ea75980 100644
--- a/spec/ruby/shared/process/fork.rb
+++ b/spec/ruby/shared/process/fork.rb
@@ -1,18 +1,18 @@
describe :process_fork, shared: true do
- platform_is :windows do
+ guard_not -> { Process.respond_to?(:fork) } do
it "returns false from #respond_to?" do
# Workaround for Kernel::Method being public and losing the "non-respond_to? magic"
mod = @object.class.name == "KernelSpecs::Method" ? Object.new : @object
- mod.respond_to?(:fork).should be_false
- mod.respond_to?(:fork, true).should be_false
+ mod.respond_to?(:fork).should == false
+ mod.respond_to?(:fork, true).should == false
end
it "raises a NotImplementedError when called" do
- -> { @object.fork }.should raise_error(NotImplementedError)
+ -> { @object.fork }.should.raise(NotImplementedError)
end
end
- platform_is_not :windows do
+ guard -> { Process.respond_to?(:fork) } do
before :each do
@file = tmp('i_exist')
rm_r @file
@@ -74,16 +74,19 @@ describe :process_fork, shared: true do
it "marks threads from the parent as killed" do
t = Thread.new { sleep }
- pid = @object.fork {
- touch(@file) do |f|
- f.write Thread.current.alive?
- f.write t.alive?
- end
- Process.exit!
- }
- Process.waitpid(pid)
- t.kill
- t.join
+ begin
+ pid = @object.fork {
+ touch(@file) do |f|
+ f.write Thread.current.alive?
+ f.write t.alive?
+ end
+ Process.exit!
+ }
+ Process.waitpid(pid)
+ ensure
+ t.kill
+ t.join
+ end
File.read(@file).should == "truefalse"
end
end