|
22 | 22 | sock.close |
23 | 23 | end |
24 | 24 |
|
25 | | - it "returns an array with data and information on the sender" do |
26 | | - @client.send("foobar", 0) |
27 | | - sock = @server.accept |
28 | | - data = sock.recvfrom(6) |
29 | | - data.first.should == "foobar" |
30 | | - data.last.should == ["AF_UNIX", ""] |
31 | | - sock.close |
| 25 | + platform_is_not :windows do |
| 26 | + it "returns an array with data and information on the sender" do |
| 27 | + @client.send("foobar", 0) |
| 28 | + sock = @server.accept |
| 29 | + data = sock.recvfrom(6) |
| 30 | + data.first.should == "foobar" |
| 31 | + data.last.should == ["AF_UNIX", ""] |
| 32 | + sock.close |
| 33 | + end |
| 34 | + end |
| 35 | + |
| 36 | + platform_is :windows do |
| 37 | + it "returns an Array containing the data and address information" do |
| 38 | + # The second part of the address is a memory dump on Windows! |
| 39 | + (@server.recvfrom(6) in ["foobar", ["AF_UNIX", String]]).should be_true |
| 40 | + end |
32 | 41 | end |
33 | 42 |
|
34 | 43 | it "allows an output buffer as third argument" do |
|
54 | 63 | buffer.encoding.should == Encoding::ISO_8859_1 |
55 | 64 | end |
56 | 65 |
|
57 | | - it "uses different message options" do |
58 | | - @client.send("foobar", Socket::MSG_PEEK) |
59 | | - sock = @server.accept |
60 | | - peek_data = sock.recvfrom(6, Socket::MSG_PEEK) # Does not retrieve the message |
61 | | - real_data = sock.recvfrom(6) |
| 66 | + platform_is_not :windows do |
| 67 | + it "uses different message options" do |
| 68 | + @client.send("foobar", Socket::MSG_PEEK) |
| 69 | + sock = @server.accept |
| 70 | + peek_data = sock.recvfrom(6, Socket::MSG_PEEK) # Does not retrieve the message |
| 71 | + real_data = sock.recvfrom(6) |
62 | 72 |
|
63 | | - real_data.should == peek_data |
64 | | - peek_data.should == ["foobar", ["AF_UNIX", ""]] |
65 | | - sock.close |
| 73 | + real_data.should == peek_data |
| 74 | + peek_data.should == ["foobar", ["AF_UNIX", ""]] |
| 75 | + sock.close |
| 76 | + end |
66 | 77 | end |
67 | 78 | end |
68 | 79 |
|
|
78 | 89 | @server.close |
79 | 90 | end |
80 | 91 |
|
81 | | - it 'returns an Array containing the data and address information' do |
82 | | - @server.recvfrom(5).should == ['hello', ['AF_UNIX', '']] |
| 92 | + platform_is_not :windows do |
| 93 | + it 'returns an Array containing the data and address information' do |
| 94 | + @server.recvfrom(5).should == ['hello', ['AF_UNIX', '']] |
| 95 | + end |
| 96 | + end |
| 97 | + |
| 98 | + platform_is :windows do |
| 99 | + it 'returns an Array containing the data and address information' do |
| 100 | + # The second part of the address is a memory dump on Windows! |
| 101 | + (@server.recvfrom(5) in ['hello', ['AF_UNIX', String]]).should be_true |
| 102 | + end |
83 | 103 | end |
84 | 104 | end |
85 | 105 |
|
86 | | - # These specs are taken from the rdoc examples on UNIXSocket#recvfrom. |
87 | | - describe 'using a UNIX socket constructed using UNIXSocket.for_fd' do |
88 | | - before do |
89 | | - @path1 = SocketSpecs.socket_path |
90 | | - @path2 = SocketSpecs.socket_path.chop + '2' |
91 | | - rm_r(@path2) |
| 106 | + platform_is_not :windows do |
| 107 | + # These specs are taken from the rdoc examples on UNIXSocket#recvfrom. |
| 108 | + describe 'using a UNIX socket constructed using UNIXSocket.for_fd' do |
| 109 | + before do |
| 110 | + @path1 = SocketSpecs.socket_path |
| 111 | + @path2 = SocketSpecs.socket_path.chop + '2' |
| 112 | + rm_r(@path2) |
92 | 113 |
|
93 | | - @client_raw = Socket.new(:UNIX, :DGRAM) |
94 | | - @client_raw.bind(Socket.sockaddr_un(@path1)) |
| 114 | + @client_raw = Socket.new(:UNIX, :DGRAM) |
| 115 | + @client_raw.bind(Socket.sockaddr_un(@path1)) |
95 | 116 |
|
96 | | - @server_raw = Socket.new(:UNIX, :DGRAM) |
97 | | - @server_raw.bind(Socket.sockaddr_un(@path2)) |
| 117 | + @server_raw = Socket.new(:UNIX, :DGRAM) |
| 118 | + @server_raw.bind(Socket.sockaddr_un(@path2)) |
98 | 119 |
|
99 | | - @socket = UNIXSocket.for_fd(@server_raw.fileno) |
100 | | - @socket.autoclose = false |
101 | | - end |
| 120 | + @socket = UNIXSocket.for_fd(@server_raw.fileno) |
| 121 | + @socket.autoclose = false |
| 122 | + end |
102 | 123 |
|
103 | | - after do |
104 | | - @client_raw.close |
105 | | - @server_raw.close # also closes @socket |
| 124 | + after do |
| 125 | + @client_raw.close |
| 126 | + @server_raw.close # also closes @socket |
106 | 127 |
|
107 | | - rm_r @path1 |
108 | | - rm_r @path2 |
109 | | - end |
| 128 | + rm_r @path1 |
| 129 | + rm_r @path2 |
| 130 | + end |
110 | 131 |
|
111 | | - it 'returns an Array containing the data and address information' do |
112 | | - @client_raw.send('hello', 0, Socket.sockaddr_un(@path2)) |
| 132 | + it 'returns an Array containing the data and address information' do |
| 133 | + @client_raw.send('hello', 0, Socket.sockaddr_un(@path2)) |
113 | 134 |
|
114 | | - @socket.recvfrom(5).should == ['hello', ['AF_UNIX', @path1]] |
| 135 | + @socket.recvfrom(5).should == ['hello', ['AF_UNIX', @path1]] |
| 136 | + end |
115 | 137 | end |
116 | 138 | end |
117 | 139 | end |
|
0 commit comments