mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aeeaadaad0
commit
b53cf149ad
246 changed files with 9108 additions and 548 deletions
|
@ -1,7 +1,7 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
|
||||
describe "UDPSocket.send" do
|
||||
describe "UDPSocket#send" do
|
||||
before :each do
|
||||
@port = nil
|
||||
@server_thread = Thread.new do
|
||||
|
@ -76,3 +76,79 @@ describe "UDPSocket.send" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'UDPSocket#send' do
|
||||
SocketSpecs.each_ip_protocol do |family, ip_address|
|
||||
before do
|
||||
@server = UDPSocket.new(family)
|
||||
@client = UDPSocket.new(family)
|
||||
|
||||
@server.bind(ip_address, 0)
|
||||
|
||||
@addr = @server.connect_address
|
||||
end
|
||||
|
||||
after do
|
||||
@server.close
|
||||
@client.close
|
||||
end
|
||||
|
||||
describe 'using a disconnected socket' do
|
||||
describe 'without a destination address' do
|
||||
it "raises #{SocketSpecs.dest_addr_req_error}" do
|
||||
lambda { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with a destination address as separate arguments' do
|
||||
it 'returns the amount of sent bytes' do
|
||||
@client.send('hello', 0, @addr.ip_address, @addr.ip_port).should == 5
|
||||
end
|
||||
|
||||
it 'does not persist the connection after sending data' do
|
||||
@client.send('hello', 0, @addr.ip_address, @addr.ip_port)
|
||||
|
||||
lambda { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with a destination address as a single String argument' do
|
||||
it 'returns the amount of sent bytes' do
|
||||
@client.send('hello', 0, @server.getsockname).should == 5
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'using a connected socket' do
|
||||
describe 'without an explicit destination address' do
|
||||
before do
|
||||
@client.connect(@addr.ip_address, @addr.ip_port)
|
||||
end
|
||||
|
||||
it 'returns the amount of bytes written' do
|
||||
@client.send('hello', 0).should == 5
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with an explicit destination address' do
|
||||
before do
|
||||
@alt_server = UDPSocket.new(family)
|
||||
|
||||
@alt_server.bind(ip_address, 0)
|
||||
end
|
||||
|
||||
after do
|
||||
@alt_server.close
|
||||
end
|
||||
|
||||
it 'sends the data to the given address instead' do
|
||||
@client.send('hello', 0, @alt_server.getsockname).should == 5
|
||||
|
||||
lambda { @server.recv(5) }.should block_caller
|
||||
|
||||
@alt_server.recv(5).should == 'hello'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue