mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Don't try to read empty responses (fixes issues on jruby)
This commit is contained in:
parent
665e0fc729
commit
99c3c9ae73
2 changed files with 19 additions and 3 deletions
|
@ -143,9 +143,13 @@ class Capybara::Driver::Webkit
|
||||||
|
|
||||||
def read_response
|
def read_response
|
||||||
response_length = @connection.gets.to_i
|
response_length = @connection.gets.to_i
|
||||||
response = @connection.read(response_length)
|
if response_length > 0
|
||||||
response.force_encoding("UTF-8") if response.respond_to?(:force_encoding)
|
response = @connection.read(response_length)
|
||||||
response
|
response.force_encoding("UTF-8") if response.respond_to?(:force_encoding)
|
||||||
|
response
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_proxy_options
|
def default_proxy_options
|
||||||
|
|
|
@ -158,4 +158,16 @@ describe Capybara::Driver::Webkit::Browser do
|
||||||
@proxy_requests.size.should == 0
|
@proxy_requests.size.should == 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't try to read an empty response" do
|
||||||
|
connection = stub("connection")
|
||||||
|
connection.stub(:puts)
|
||||||
|
connection.stub(:print)
|
||||||
|
connection.stub(:gets).and_return("ok\n", "0\n")
|
||||||
|
connection.stub(:read).and_raise(StandardError.new("tried to read empty response"))
|
||||||
|
|
||||||
|
browser = Capybara::Driver::Webkit::Browser.new(connection)
|
||||||
|
|
||||||
|
expect { browser.visit("/") }.not_to raise_error(/empty response/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue