File tree Expand file tree Collapse file tree 8 files changed +61
-2
lines changed Expand file tree Collapse file tree 8 files changed +61
-2
lines changed Original file line number Diff line number Diff line change 188
188
} . should raise_error ( Errno ::EEXIST , /File exists/ )
189
189
end
190
190
191
+ it "does not use the given block and warns to use File::open" do
192
+ -> {
193
+ @fh = File . new ( @file ) { raise }
194
+ } . should complain ( /warning: File::new\( \) does not take block; use File::open\( \) instead/ )
195
+ end
196
+
191
197
it "raises a TypeError if the first parameter can't be coerced to a string" do
192
198
-> { File . new ( true ) } . should raise_error ( TypeError )
193
199
-> { File . new ( false ) } . should raise_error ( TypeError )
Original file line number Diff line number Diff line change 5
5
6
6
describe "IO.new" do
7
7
it_behaves_like :io_new , :new
8
+
9
+ it "does not use the given block and warns to use IO::open" do
10
+ -> {
11
+ @io = IO . send ( @method , @fd ) { raise }
12
+ } . should complain ( /warning: IO::new\( \) does not take block; use IO::open\( \) instead/ )
13
+ end
8
14
end
9
15
10
16
describe "IO.new" do
Original file line number Diff line number Diff line change 97
97
addr [ 1 ] . should be_kind_of ( Integer )
98
98
end
99
99
100
+ it "does not use the given block and warns to use TCPServer::open" do
101
+ -> {
102
+ @server = TCPServer . new ( 0 ) { raise }
103
+ } . should complain ( /warning: TCPServer::new\( \) does not take block; use TCPServer::open\( \) instead/ )
104
+ end
105
+
100
106
it "raises Errno::EADDRNOTAVAIL when the address is unknown" do
101
107
-> { TCPServer . new ( "1.2.3.4" , 0 ) } . should raise_error ( Errno ::EADDRNOTAVAIL )
102
108
end
Original file line number Diff line number Diff line change 4
4
5
5
describe 'TCPSocket#initialize' do
6
6
it_behaves_like :tcpsocket_new , :new
7
+
8
+ describe "with a running server" do
9
+ before :each do
10
+ @server = SocketSpecs ::SpecTCPServer . new
11
+ @hostname = @server . hostname
12
+ end
13
+
14
+ after :each do
15
+ if @socket
16
+ @socket . write "QUIT"
17
+ @socket . close
18
+ end
19
+ @server . shutdown
20
+ end
21
+
22
+ it "does not use the given block and warns to use TCPSocket::open" do
23
+ -> {
24
+ @socket = TCPSocket . new ( @hostname , @server . port , nil ) { raise }
25
+ } . should complain ( /warning: TCPSocket::new\( \) does not take block; use TCPSocket::open\( \) instead/ )
26
+ end
27
+ end
7
28
end
8
29
9
30
describe 'TCPSocket#initialize' do
Original file line number Diff line number Diff line change 26
26
@socket . should be_an_instance_of ( UDPSocket )
27
27
end
28
28
29
+ it "does not use the given block and warns to use UDPSocket::open" do
30
+ -> {
31
+ @socket = UDPSocket . new { raise }
32
+ } . should complain ( /warning: UDPSocket::new\( \) does not take block; use UDPSocket::open\( \) instead/ )
33
+ end
34
+
29
35
it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT if unsupported family passed' do
30
36
-> { UDPSocket . new ( -1 ) } . should raise_error ( SystemCallError ) { |e |
31
37
[ Errno ::EAFNOSUPPORT , Errno ::EPROTONOSUPPORT ] . should include ( e . class )
Original file line number Diff line number Diff line change 4
4
with_feature :unix_socket do
5
5
describe "UNIXServer.new" do
6
6
it_behaves_like :unixserver_new , :new
7
+
8
+ it "does not use the given block and warns to use UNIXServer::open" do
9
+ -> {
10
+ @server = UNIXServer . new ( @path ) { raise }
11
+ } . should complain ( /warning: UNIXServer::new\( \) does not take block; use UNIXServer::open\( \) instead/ )
12
+ end
7
13
end
8
14
end
Original file line number Diff line number Diff line change 4
4
with_feature :unix_socket do
5
5
describe "UNIXSocket.new" do
6
6
it_behaves_like :unixsocket_new , :new
7
+
8
+ it "does not use the given block and warns to use UNIXSocket::open" do
9
+ -> {
10
+ @client = UNIXSocket . new ( @path ) { raise }
11
+ } . should complain ( /warning: UNIXSocket::new\( \) does not take block; use UNIXSocket::open\( \) instead/ )
12
+ end
7
13
end
8
14
end
Original file line number Diff line number Diff line change 2
2
require 'stringio'
3
3
4
4
describe "StringIO.new" do
5
- it "warns when called with a block" do
6
- -> { eval ( "StringIO.new {}" ) } . should complain ( /StringIO::new\( \) does not take block; use StringIO::open\( \) instead/ )
5
+ it "does not use the given block and warns to use StringIO::open" do
6
+ -> {
7
+ StringIO . new { raise }
8
+ } . should complain ( /warning: StringIO::new\( \) does not take block; use StringIO::open\( \) instead/ )
7
9
end
8
10
end
You can’t perform that action at this time.
0 commit comments