File tree Expand file tree Collapse file tree 2 files changed +33
-36
lines changed
Expand file tree Collapse file tree 2 files changed +33
-36
lines changed Original file line number Diff line number Diff line change 55describe "File.socket?" do
66 it_behaves_like :file_socket , :socket? , File
77end
8-
9- describe "File.socket?" do
10- it "returns false if file does not exist" do
11- File . socket? ( "I_am_a_bogus_file" ) . should == false
12- end
13-
14- it "returns false if the file is not a socket" do
15- filename = tmp ( "i_exist" )
16- touch ( filename )
17-
18- File . socket? ( filename ) . should == false
19-
20- rm_r filename
21- end
22- end
23-
24- platform_is_not :windows do
25- describe "File.socket?" do
26- before :each do
27- # We need a really short name here.
28- # On Linux the path length is limited to 107, see unix(7).
29- @name = tmp ( "s" )
30- @server = UNIXServer . new @name
31- end
32-
33- after :each do
34- @server . close
35- rm_r @name
36- end
37-
38- it "returns true if the file is a socket" do
39- File . socket? ( @name ) . should == true
40- end
41- end
42- end
Original file line number Diff line number Diff line change 11describe :file_socket , shared : true do
2- it "accepts an object that has a #to_path method"
2+ it "returns false if file does not exist" do
3+ File . socket? ( "I_am_a_bogus_file" ) . should == false
4+ end
5+
6+ it "returns false if the file is not a socket" do
7+ filename = tmp ( "i_exist" )
8+ touch ( filename )
9+
10+ File . socket? ( filename ) . should == false
11+
12+ rm_r filename
13+ end
14+
15+ it "returns true if the file is a socket" do
16+ # We need a really short name here.
17+ # On Linux the path length is limited to 107, see unix(7).
18+ name = tmp ( "s" )
19+ server = UNIXServer . new ( name )
20+
21+ File . socket? ( name ) . should == true
22+
23+ server . close
24+ rm_r name
25+ end
26+
27+ it "accepts an object that has a #to_path method" do
28+ obj = Object . new
29+ def obj . to_path
30+ __FILE__
31+ end
32+
33+ File . socket? ( obj ) . should == false
34+ end
335end
You can’t perform that action at this time.
0 commit comments