diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-01-28 17:08:57 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2021-01-28 17:08:57 +0100 |
commit | 2e32b919b4f2f5b7f2e1509d6fa985526ef1f61c (patch) | |
tree | aedadac3c99ca0097c2bbeaa95830332d6fb9971 /spec/ruby/library | |
parent | 1b377b32c8616f85c0a97e68758c5c2db83f2169 (diff) |
Update to ruby/spec@8cafaa5
Diffstat (limited to 'spec/ruby/library')
4 files changed, 39 insertions, 0 deletions
diff --git a/spec/ruby/library/pathname/inspect_spec.rb b/spec/ruby/library/pathname/inspect_spec.rb new file mode 100644 index 0000000000..304746fbe5 --- /dev/null +++ b/spec/ruby/library/pathname/inspect_spec.rb @@ -0,0 +1,10 @@ +require_relative '../../spec_helper' +require 'pathname' + +describe "Pathname#inspect" do + it "returns a consistent String" do + result = Pathname.new('/tmp').inspect + result.should be_an_instance_of(String) + result.should == "#<Pathname:/tmp>" + end +end diff --git a/spec/ruby/library/socket/basicsocket/send_spec.rb b/spec/ruby/library/socket/basicsocket/send_spec.rb index 041ee46998..868801df30 100644 --- a/spec/ruby/library/socket/basicsocket/send_spec.rb +++ b/spec/ruby/library/socket/basicsocket/send_spec.rb @@ -99,6 +99,14 @@ describe 'BasicSocket#send' do @server.close end + describe 'with an object implementing #to_str' do + it 'returns the amount of sent bytes' do + data = mock('message') + data.should_receive(:to_str).and_return('hello') + @client.send(data, 0, @server.getsockname).should == 5 + end + end + describe 'without a destination address' do it "raises #{SocketSpecs.dest_addr_req_error}" do -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error) diff --git a/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb b/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb index bfd815c658..6ce5a41b58 100644 --- a/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb @@ -27,6 +27,20 @@ describe "TCPSocket#recv_nonblock" do @socket.recv_nonblock(50).should == "TCPSocket#recv_nonblock" end + it 'writes the read to a buffer from the socket' do + @socket = TCPSocket.new @hostname, @server.port + @socket.write "TCPSocket#recv_nonblock" + + # Wait for the server to echo. This spec is testing the return + # value, not the non-blocking behavior. + # + # TODO: Figure out a good way to test non-blocking. + IO.select([@socket]) + buffer = "".b + @socket.recv_nonblock(50, 0, buffer) + buffer.should == 'TCPSocket#recv_nonblock' + end + it 'returns :wait_readable in exceptionless mode' do @socket = TCPSocket.new @hostname, @server.port @socket.recv_nonblock(50, exception: false).should == :wait_readable diff --git a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb b/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb index c66d1df84d..650a061221 100644 --- a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb +++ b/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb @@ -51,6 +51,13 @@ describe 'UDPSocket#recvfrom_nonblock' do @server.recvfrom_nonblock(1).should be_an_instance_of(Array) end + it 'writes the data to the buffer when one is present' do + buffer = "".b + IO.select([@server]) + @server.recvfrom_nonblock(1, 0, buffer) + buffer.should == 'h' + end + describe 'the returned Array' do before do IO.select([@server]) |