Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Basic specs for UNIXSocket.{new,open}.

  • Loading branch information...
commit 7ed611d7e3a5050d6346d7aeb9d21914636a088f 1 parent 236e57b
@headius headius authored
View
21 library/socket/unixsocket/open_spec.rb
@@ -3,4 +3,25 @@
describe "UNIXSocket.open" do
it_behaves_like :unixsocket_new, :open
+
+ platform_is_not :windows do
+ before :each do
+ @path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
+
+ @server = UNIXServer.open(@path)
+ end
+
+ after :each do
+ @server.close
+ File.unlink(@path) if File.exists?(@path)
+ end
+
+ it "opens a unix socket on the specified file and yields it to the block" do
+ UNIXSocket.send(@method, @path) do |client|
+ client.addr[0].should == "AF_UNIX"
+ client.closed?.should == false
+ end
+ end
+ end
end
View
22 library/socket/unixsocket/shared/new.rb
@@ -1,4 +1,26 @@
require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/classes', __FILE__)
describe :unixsocket_new, :shared => true do
+ platform_is_not :windows do
+ before :each do
+ @path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
+
+ @server = UNIXServer.open(@path)
+ end
+
+ after :each do
+ @server.close if @server && !@server.closed?
+ @server = nil
+ File.unlink(@path) rescue nil
+ end
+
+ it "opens a unix socket on the specified file" do
+ client = UNIXSocket.send(@method, @path)
+
+ client.addr[0].should == "AF_UNIX"
+ client.closed?.should == false
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.