Skip to content

Commit 978823f

Browse files
herwinweregon
authored andcommitted
Wrap tests for unixserver in an outer guard block
Normalize to `with_feature :unix_socket`, which is more descriptive and generic than checking for windows.
1 parent 7c8139f commit 978823f

File tree

6 files changed

+23
-26
lines changed

6 files changed

+23
-26
lines changed

library/socket/unixserver/accept_nonblock_spec.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
require_relative '../spec_helper'
22
require_relative '../fixtures/classes'
33

4-
describe "UNIXServer#accept_nonblock" do
5-
6-
platform_is_not :windows do
4+
with_feature :unix_socket do
5+
describe "UNIXServer#accept_nonblock" do
76
before :each do
87
@path = SocketSpecs.socket_path
98
@server = UNIXServer.open(@path)
@@ -33,9 +32,7 @@
3332
@server.accept_nonblock(exception: false).should == :wait_readable
3433
end
3534
end
36-
end
3735

38-
with_feature :unix_socket do
3936
describe 'UNIXServer#accept_nonblock' do
4037
before do
4138
@path = SocketSpecs.socket_path

library/socket/unixserver/accept_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../spec_helper'
22
require_relative '../fixtures/classes'
33

4-
platform_is_not :windows do
4+
with_feature :unix_socket do
55
describe "UNIXServer#accept" do
66
before :each do
77
@path = SocketSpecs.socket_path

library/socket/unixserver/for_fd_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../spec_helper'
22
require_relative '../fixtures/classes'
33

4-
platform_is_not :windows do
4+
with_feature :unix_socket do
55
describe "UNIXServer#for_fd" do
66
before :each do
77
@unix_path = SocketSpecs.socket_path

library/socket/unixserver/new_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require_relative '../spec_helper'
22
require_relative 'shared/new'
33

4-
describe "UNIXServer.new" do
5-
it_behaves_like :unixserver_new, :new
4+
with_feature :unix_socket do
5+
describe "UNIXServer.new" do
6+
it_behaves_like :unixserver_new, :new
7+
end
68
end

library/socket/unixserver/open_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
require_relative '../fixtures/classes'
33
require_relative 'shared/new'
44

5-
describe "UNIXServer.open" do
6-
it_behaves_like :unixserver_new, :open
5+
with_feature :unix_socket do
6+
describe "UNIXServer.open" do
7+
it_behaves_like :unixserver_new, :open
78

8-
platform_is_not :windows do
99
before :each do
1010
@path = SocketSpecs.socket_path
1111
end

library/socket/unixserver/shared/new.rb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
require_relative '../../fixtures/classes'
33

44
describe :unixserver_new, shared: true do
5-
platform_is_not :windows do
6-
before :each do
7-
@path = SocketSpecs.socket_path
8-
end
5+
before :each do
6+
@path = SocketSpecs.socket_path
7+
end
98

10-
after :each do
11-
@server.close if @server
12-
@server = nil
13-
SocketSpecs.rm_socket @path
14-
end
9+
after :each do
10+
@server.close if @server
11+
@server = nil
12+
SocketSpecs.rm_socket @path
13+
end
1514

16-
it "creates a new UNIXServer" do
17-
@server = UNIXServer.send(@method, @path)
18-
@server.path.should == @path
19-
@server.addr.should == ["AF_UNIX", @path]
20-
end
15+
it "creates a new UNIXServer" do
16+
@server = UNIXServer.send(@method, @path)
17+
@server.path.should == @path
18+
@server.addr.should == ["AF_UNIX", @path]
2119
end
2220
end

0 commit comments

Comments
 (0)