File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
spec/ruby/library/socket/unixsocket Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 47
47
end
48
48
end
49
49
end
50
+
51
+ with_feature :unix_socket do
52
+ describe 'UNIXSocket#local_address with a UNIX socket pair' do
53
+ before :each do
54
+ @sock , @sock2 = Socket . pair ( Socket ::AF_UNIX , Socket ::SOCK_STREAM )
55
+ end
56
+
57
+ after :each do
58
+ @sock . close
59
+ @sock2 . close
60
+ end
61
+
62
+ it 'returns an Addrinfo' do
63
+ @sock . local_address . should be_an_instance_of ( Addrinfo )
64
+ end
65
+
66
+ describe 'the returned Addrinfo' do
67
+ it 'uses AF_UNIX as the address family' do
68
+ @sock . local_address . afamily . should == Socket ::AF_UNIX
69
+ end
70
+
71
+ it 'uses PF_UNIX as the protocol family' do
72
+ @sock . local_address . pfamily . should == Socket ::PF_UNIX
73
+ end
74
+
75
+ it 'uses SOCK_STREAM as the socket type' do
76
+ @sock . local_address . socktype . should == Socket ::SOCK_STREAM
77
+ end
78
+
79
+ it 'raises SocketError for #ip_address' do
80
+ -> {
81
+ @sock . local_address . ip_address
82
+ } . should raise_error ( SocketError , "need IPv4 or IPv6 address" )
83
+ end
84
+
85
+ it 'raises SocketError for #ip_port' do
86
+ -> {
87
+ @sock . local_address . ip_port
88
+ } . should raise_error ( SocketError , "need IPv4 or IPv6 address" )
89
+ end
90
+
91
+ it 'uses 0 as the protocol' do
92
+ @sock . local_address . protocol . should == 0
93
+ end
94
+ end
95
+ end
96
+ end
You can’t perform that action at this time.
0 commit comments