Skip to content

Commit

Permalink
add ReadError test
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Feb 24, 2010
1 parent d8882f3 commit 56ec0fc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/action_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ class ActionTest < Test::Unit::TestCase
assert_equal 9941, e.port
end
end

should "raise a ReadError when the socket becomes unreadable" do
io = stub()
io.expects(:write).with("\000\000\000\003")
io.expects(:write).with("foo")
@call.expects(:read).with(io, 4, nil).raises(Errno::ECONNRESET)
@call.expects(:connect_to).returns(io)
begin
@call.transaction("foo")
fail "Should have thrown an error"
rescue BERTRPC::ReadError => e
assert_equal 0, e.code
assert_equal 'localhost', e.host
assert_equal 9941, e.port
end
end
end
end
end

0 comments on commit 56ec0fc

Please sign in to comment.