Skip to content

Commit ae3c291

Browse files
added test for Basic#send with an object implementing #to_str
1 parent 4df7a45 commit ae3c291

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/ruby/library/socket/basicsocket/send_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@
9999
@server.close
100100
end
101101

102+
describe 'with an object implementing #to_str' do
103+
it 'returns the amount of sent bytes' do
104+
data = Class.new do
105+
def to_str
106+
'hello'
107+
end
108+
end.new
109+
@client.send(data, 0, @server.getsockname).should == 5
110+
end
111+
end
112+
102113
describe 'without a destination address' do
103114
it "raises #{SocketSpecs.dest_addr_req_error}" do
104115
-> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error)

0 commit comments

Comments
 (0)