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