2018-08-03 12:19:40 -04:00
|
|
|
require_relative '../spec_helper'
|
2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../fixtures/classes'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Addrinfo#bind" do
|
|
|
|
|
|
|
|
before :each do
|
2017-06-15 08:48:52 -04:00
|
|
|
@addrinfo = Addrinfo.tcp("127.0.0.1", 0)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
after :each do
|
|
|
|
@socket.close unless @socket.closed?
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a bound socket when no block is given" do
|
|
|
|
@socket = @addrinfo.bind
|
|
|
|
@socket.should be_kind_of(Socket)
|
|
|
|
@socket.closed?.should be_false
|
|
|
|
end
|
|
|
|
|
|
|
|
it "yields the socket if a block is given" do
|
|
|
|
@addrinfo.bind do |sock|
|
|
|
|
@socket = sock
|
|
|
|
sock.should be_kind_of(Socket)
|
|
|
|
end
|
|
|
|
@socket.closed?.should be_true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|