Permalink
Browse files

Failing tests for cases where a non-blocking socket should raise

Works correctly on MRI (1.9.3 & 2.0.0-preview1) and Rubinius, but not JRuby 1.7
  • Loading branch information...
1 parent 71974ba commit dc04fcdd465628faf7bddc565dd878d2a0b469c7 @benlangfeld benlangfeld committed Nov 18, 2012
Showing with 21 additions and 3 deletions.
  1. +15 −0 spec/celluloid/io/tcp_socket_spec.rb
  2. +6 −3 spec/spec_helper.rb
@@ -72,6 +72,21 @@
peer.read(payload.size).should eq payload
end
end
+
+ it "raises Errno::ECONNREFUSED when the connection is refused" do
+ expect {
+ within_io_actor { ::TCPSocket.new(example_addr, example_port) }
+ }.to raise_error(Errno::ECONNREFUSED)
+ end
+
+ it "raises EOFError when partial reading from a closed socket" do
+ with_connected_sockets do |subject, peer|
+ peer.close
+ expect {
+ within_io_actor { subject.readpartial(payload.size) }
+ }.to raise_error(EOFError)
+ end
+ end
end
context "elsewhere in Ruby" do
View
@@ -20,7 +20,7 @@ def within_io_actor(&block)
actor = ExampleActor.new
actor.wrap(&block)
ensure
- actor.terminate
+ actor.terminate if actor.alive?
end
def with_tcp_server
@@ -41,8 +41,11 @@ def with_connected_sockets
begin
yield peer, client
ensure
- client.close
- peer.close
+ begin
+ client.close
+ peer.close
+ rescue
+ end
end
end
end

6 comments on commit dc04fcd

Owner

tarcieri replied Dec 13, 2012

@benlangfeld can you confirm this is fixed now?

Member

benlangfeld replied Dec 13, 2012

Coming right up

Member

benlangfeld replied Dec 13, 2012

Confirmed good. Any chance of getting this out as 0.12.1, assuming 0.13.0 will take a while?

Owner

tarcieri replied Dec 13, 2012

Sure...

Owner

tarcieri replied Dec 13, 2012

0.12.1 released

Member

benlangfeld replied Dec 13, 2012

Thanks :)

Please sign in to comment.