diff options
Diffstat (limited to 'spec/rubyspec/library/socket/tcpsocket/setsockopt_spec.rb')
-rw-r--r-- | spec/rubyspec/library/socket/tcpsocket/setsockopt_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/rubyspec/library/socket/tcpsocket/setsockopt_spec.rb b/spec/rubyspec/library/socket/tcpsocket/setsockopt_spec.rb new file mode 100644 index 0000000000..e4d3da10d1 --- /dev/null +++ b/spec/rubyspec/library/socket/tcpsocket/setsockopt_spec.rb @@ -0,0 +1,48 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require File.expand_path('../../fixtures/classes', __FILE__) + +describe "TCPSocket#setsockopt" do + before :each do + @server = SocketSpecs::SpecTCPServer.new + @hostname = @server.hostname + end + + before :each do + @sock = TCPSocket.new @hostname, SocketSpecs.port + end + + after :each do + @sock.close unless @sock.closed? + @server.shutdown + end + + describe "using constants" do + it "sets the TCP nodelay to 1" do + @sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1).should == 0 + end + end + + describe "using symbols" do + it "sets the TCP nodelay to 1" do + @sock.setsockopt(:IPPROTO_TCP, :TCP_NODELAY, 1).should == 0 + end + + context "without prefix" do + it "sets the TCP nodelay to 1" do + @sock.setsockopt(:TCP, :NODELAY, 1).should == 0 + end + end + end + + describe "using strings" do + it "sets the TCP nodelay to 1" do + @sock.setsockopt('IPPROTO_TCP', 'TCP_NODELAY', 1).should == 0 + end + + context "without prefix" do + it "sets the TCP nodelay to 1" do + @sock.setsockopt('TCP', 'NODELAY', 1).should == 0 + end + end + end +end
\ No newline at end of file |