From cc6b910634d1c132d98f1e6d6131b8be433c79a4 Mon Sep 17 00:00:00 2001 From: Matthew Horan Date: Thu, 17 Jul 2014 09:35:45 -0400 Subject: [PATCH] Make Connection#gets non-blocking * JRuby Timeout::timeout blocks on IO#gets. IO.connect blocks as well unless running in its own thread. --- lib/capybara/webkit/connection.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/capybara/webkit/connection.rb b/lib/capybara/webkit/connection.rb index 1cf2ac5..5f578bc 100644 --- a/lib/capybara/webkit/connection.rb +++ b/lib/capybara/webkit/connection.rb @@ -35,7 +35,13 @@ module Capybara::Webkit end def gets - @socket.gets + response = "" + + while !response.match(/\n/) && Thread.new { IO.select([@socket]) }.join do + response += @socket.read_nonblock(1) + end + + response end def read(length)