diff options
Diffstat (limited to 'spec/ruby/library/socket/unixserver')
6 files changed, 41 insertions, 27 deletions
diff --git a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb index 30688b46b6..dba3de7359 100644 --- a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb @@ -1,9 +1,8 @@ require_relative '../spec_helper' require_relative '../fixtures/classes' -describe "UNIXServer#accept_nonblock" do - - platform_is_not :windows do +with_feature :unix_socket do + describe "UNIXServer#accept_nonblock" do before :each do @path = SocketSpecs.socket_path @server = UNIXServer.open(@path) @@ -33,9 +32,7 @@ describe "UNIXServer#accept_nonblock" do @server.accept_nonblock(exception: false).should == :wait_readable end end -end -with_feature :unix_socket do describe 'UNIXServer#accept_nonblock' do before do @path = SocketSpecs.socket_path diff --git a/spec/ruby/library/socket/unixserver/accept_spec.rb b/spec/ruby/library/socket/unixserver/accept_spec.rb index c05fbe7f22..1305bc6220 100644 --- a/spec/ruby/library/socket/unixserver/accept_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_spec.rb @@ -1,7 +1,7 @@ require_relative '../spec_helper' require_relative '../fixtures/classes' -platform_is_not :windows do +with_feature :unix_socket do describe "UNIXServer#accept" do before :each do @path = SocketSpecs.socket_path @@ -110,6 +110,17 @@ with_feature :unix_socket do @socket = @server.accept @socket.recv(5).should == 'hello' end + + it "is set to nonblocking" do + require 'io/nonblock' + @socket = @server.accept + @socket.should.nonblock? + end + + it "is set to close on exec" do + @socket = @server.accept + @socket.should.close_on_exec? + end end end end diff --git a/spec/ruby/library/socket/unixserver/for_fd_spec.rb b/spec/ruby/library/socket/unixserver/for_fd_spec.rb index 4f3816ad37..8cc55ef391 100644 --- a/spec/ruby/library/socket/unixserver/for_fd_spec.rb +++ b/spec/ruby/library/socket/unixserver/for_fd_spec.rb @@ -1,8 +1,8 @@ require_relative '../spec_helper' require_relative '../fixtures/classes' -platform_is_not :windows do - describe "UNIXServer#for_fd" do +with_feature :unix_socket do + describe "UNIXServer.for_fd" do before :each do @unix_path = SocketSpecs.socket_path @unix = UNIXServer.new(@unix_path) diff --git a/spec/ruby/library/socket/unixserver/new_spec.rb b/spec/ruby/library/socket/unixserver/new_spec.rb index f831f40bc6..a160e3ce5c 100644 --- a/spec/ruby/library/socket/unixserver/new_spec.rb +++ b/spec/ruby/library/socket/unixserver/new_spec.rb @@ -1,6 +1,14 @@ require_relative '../spec_helper' require_relative 'shared/new' -describe "UNIXServer.new" do - it_behaves_like :unixserver_new, :new +with_feature :unix_socket do + describe "UNIXServer.new" do + it_behaves_like :unixserver_new, :new + + it "does not use the given block and warns to use UNIXServer::open" do + -> { + @server = UNIXServer.new(@path) { raise } + }.should complain(/warning: UNIXServer::new\(\) does not take block; use UNIXServer::open\(\) instead/) + end + end end diff --git a/spec/ruby/library/socket/unixserver/open_spec.rb b/spec/ruby/library/socket/unixserver/open_spec.rb index f2506d9f6f..16453dd3bd 100644 --- a/spec/ruby/library/socket/unixserver/open_spec.rb +++ b/spec/ruby/library/socket/unixserver/open_spec.rb @@ -2,10 +2,10 @@ require_relative '../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/new' -describe "UNIXServer.open" do - it_behaves_like :unixserver_new, :open +with_feature :unix_socket do + describe "UNIXServer.open" do + it_behaves_like :unixserver_new, :open - platform_is_not :windows do before :each do @path = SocketSpecs.socket_path end diff --git a/spec/ruby/library/socket/unixserver/shared/new.rb b/spec/ruby/library/socket/unixserver/shared/new.rb index 35395826c9..b537f2a871 100644 --- a/spec/ruby/library/socket/unixserver/shared/new.rb +++ b/spec/ruby/library/socket/unixserver/shared/new.rb @@ -2,21 +2,19 @@ require_relative '../../spec_helper' require_relative '../../fixtures/classes' describe :unixserver_new, shared: true do - platform_is_not :windows do - before :each do - @path = SocketSpecs.socket_path - end + before :each do + @path = SocketSpecs.socket_path + end - after :each do - @server.close if @server - @server = nil - SocketSpecs.rm_socket @path - end + after :each do + @server.close if @server + @server = nil + SocketSpecs.rm_socket @path + end - it "creates a new UNIXServer" do - @server = UNIXServer.send(@method, @path) - @server.path.should == @path - @server.addr.should == ["AF_UNIX", @path] - end + it "creates a new UNIXServer" do + @server = UNIXServer.send(@method, @path) + @server.path.should == @path + @server.addr.should == ["AF_UNIX", @path] end end |