Skip to content

Commit 48060b6

Browse files
ahmadsheriferegon
authored andcommitted
Add specs for File.mkfifo
1 parent 1e971da commit 48060b6

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

core/file/mkfifo_spec.rb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require File.expand_path('../../../spec_helper', __FILE__)
2+
3+
describe "File.mkfifo" do
4+
platform_is_not os: [:windows] do
5+
before do
6+
@path = tmp('fifo')
7+
end
8+
9+
after do
10+
rm_r(@path)
11+
end
12+
13+
context "when path passed responds to :to_path" do
14+
it "creates a FIFO file at the path specified" do
15+
File.mkfifo(@path)
16+
File.ftype(@path).should == "fifo"
17+
end
18+
end
19+
20+
context "when path passed is not a String value" do
21+
it "raises a TypeError" do
22+
lambda { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError)
23+
end
24+
end
25+
26+
context "when path does not exist" do
27+
it "raises an Errno::ENOENT exception" do
28+
lambda { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT)
29+
end
30+
end
31+
32+
it "creates a FIFO file at the passed path" do
33+
File.mkfifo(@path.to_s)
34+
File.ftype(@path).should == "fifo"
35+
end
36+
37+
it "creates a FIFO file with passed mode & ~umask" do
38+
File.mkfifo(@path, 0755)
39+
File.stat(@path).mode.should == 010755 & ~File.umask
40+
end
41+
42+
it "creates a FIFO file with a default mode of 0666 & ~umask" do
43+
File.mkfifo(@path)
44+
File.stat(@path).mode.should == 010666 & ~File.umask
45+
end
46+
47+
it "returns 0 after creating the FIFO file" do
48+
File.mkfifo(@path).should == 0
49+
end
50+
end
51+
end

0 commit comments

Comments
 (0)