File tree Expand file tree Collapse file tree 3 files changed +35
-33
lines changed
Expand file tree Collapse file tree 3 files changed +35
-33
lines changed Original file line number Diff line number Diff line change 11require_relative '../../spec_helper'
22require_relative '../../shared/file/socket'
3- require 'socket'
43
54describe "File.socket?" do
65 it_behaves_like :file_socket , :socket? , File
7- end
86
9- describe "File.socket?" do
107 it "returns false if file does not exist" do
118 File . socket? ( "I_am_a_bogus_file" ) . should == false
129 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
4210end
Original file line number Diff line number Diff line change 33
44describe "FileTest.socket?" do
55 it_behaves_like :file_socket , :socket? , FileTest
6+
7+ it "returns false if file does not exist" do
8+ FileTest . socket? ( "I_am_a_bogus_file" ) . should == false
9+ end
610end
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 the file is not a socket" do
3+ filename = tmp ( "i_exist" )
4+ touch ( filename )
5+
6+ @object . send ( @method , filename ) . should == false
7+
8+ rm_r filename
9+ end
10+
11+ it "returns true if the file is a socket" do
12+ require 'socket'
13+
14+ # We need a really short name here.
15+ # On Linux the path length is limited to 107, see unix(7).
16+ name = tmp ( "s" )
17+ server = UNIXServer . new ( name )
18+
19+ @object . send ( @method , name ) . should == true
20+
21+ server . close
22+ rm_r name
23+ end
24+
25+ it "accepts an object that has a #to_path method" do
26+ obj = Object . new
27+ def obj . to_path
28+ __FILE__
29+ end
30+
31+ @object . send ( @method , obj ) . should == false
32+ end
333end
You can’t perform that action at this time.
0 commit comments