diff options
Diffstat (limited to 'spec/ruby/library/socket')
-rw-r--r-- | spec/ruby/library/socket/tcpserver/accept_spec.rb | 13 | ||||
-rw-r--r-- | spec/ruby/library/socket/tcpserver/new_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/library/socket/unixserver/accept_spec.rb | 12 |
3 files changed, 14 insertions, 13 deletions
diff --git a/spec/ruby/library/socket/tcpserver/accept_spec.rb b/spec/ruby/library/socket/tcpserver/accept_spec.rb index f7b017d014..e7a1d87dbe 100644 --- a/spec/ruby/library/socket/tcpserver/accept_spec.rb +++ b/spec/ruby/library/socket/tcpserver/accept_spec.rb @@ -48,14 +48,15 @@ describe "TCPServer#accept" do end it "can be interrupted by Thread#raise" do - t = Thread.new { @server.accept } + t = Thread.new { + -> { + @server.accept + }.should raise_error(Exception, "interrupted") + } Thread.pass while t.status and t.status != "sleep" - - # raise in thread, ensure the raise happens - ex = Exception.new - t.raise ex - lambda { t.join }.should raise_error(Exception) + t.raise Exception, "interrupted" + t.join end it "raises an IOError if the socket is closed" do diff --git a/spec/ruby/library/socket/tcpserver/new_spec.rb b/spec/ruby/library/socket/tcpserver/new_spec.rb index ddbe96d89d..adbc3f303e 100644 --- a/spec/ruby/library/socket/tcpserver/new_spec.rb +++ b/spec/ruby/library/socket/tcpserver/new_spec.rb @@ -62,7 +62,7 @@ describe "TCPServer.new" do # pick such a service port that will be able to reliably bind... end - it "raises Errno::EADDRNOTAVAIL when the adress is unknown" do + it "raises Errno::EADDRNOTAVAIL when the address is unknown" do lambda { TCPServer.new("1.2.3.4", 0) }.should raise_error(Errno::EADDRNOTAVAIL) end diff --git a/spec/ruby/library/socket/unixserver/accept_spec.rb b/spec/ruby/library/socket/unixserver/accept_spec.rb index 90b22d7eb1..3921dadd9d 100644 --- a/spec/ruby/library/socket/unixserver/accept_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_spec.rb @@ -48,14 +48,14 @@ platform_is_not :windows do it "can be interrupted by Thread#raise" do t = Thread.new { - @server.accept + -> { + @server.accept + }.should raise_error(Exception, "interrupted") } - Thread.pass while t.status and t.status != "sleep" - # raise in thread, ensure the raise happens - ex = Exception.new - t.raise ex - lambda { t.join }.should raise_error(Exception) + Thread.pass while t.status and t.status != "sleep" + t.raise Exception, "interrupted" + t.join end end end |