blob: add54a097d4560ffba93ee38bac7537c61103262 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
require_relative '../spec_helper'
require_relative '../fixtures/classes'
with_feature :unix_socket do
describe 'Socket.unix' do
before do
@path = SocketSpecs.socket_path
@server = UNIXServer.new(@path)
@socket = nil
end
after do
@server.close
@socket.close if @socket
rm_r(@path)
end
describe 'when no block is given' do
it 'returns a Socket' do
@socket = Socket.unix(@path)
@socket.should be_an_instance_of(Socket)
end
end
describe 'when a block is given' do
it 'yields a Socket' do
Socket.unix(@path) do |sock|
sock.should be_an_instance_of(Socket)
end
end
it 'closes the Socket when the block returns' do
socket = nil
Socket.unix(@path) do |sock|
socket = sock
end
socket.closed?.should == true
end
end
end
end
|