Forward stderr from server to stderr, drop stdout

We don't actually write anything to stdout. Also rename the stdout
option to stderr, since that's where we forward the output.
This commit is contained in:
Matthew Horan 2013-02-02 18:32:20 -05:00
parent b06025b626
commit ea06a1b57f
3 changed files with 5 additions and 9 deletions

View File

@ -12,7 +12,7 @@ module Capybara::Webkit
def initialize(options = {})
@socket_class = options[:socket_class] || TCPSocket
@output_target = options.has_key?(:stdout) ? options[:stdout] : $stdout
@output_target = options.has_key?(:stderr) ? options[:stderr] : $stderr
start_server
connect
end
@ -73,10 +73,6 @@ module Capybara::Webkit
end
def forward_output_in_background_thread
Thread.new do
Thread.current.abort_on_exception = true
IO.copy_stream(@pipe_stdout, @output_target)
end
Thread.new do
Thread.current.abort_on_exception = true
IO.copy_stream(@pipe_stderr, @output_target)

View File

@ -18,9 +18,9 @@ describe Capybara::Webkit::Connection do
response.should include("Hey there")
end
it 'forwards stdout to the given IO object' do
it 'forwards stderr to the given IO object' do
io = StringIO.new
redirected_connection = Capybara::Webkit::Connection.new(:stdout => io)
redirected_connection = Capybara::Webkit::Connection.new(:stderr => io)
script = 'console.log("hello world")'
redirected_connection.puts "EnableLogging"
redirected_connection.puts 0
@ -29,7 +29,7 @@ describe Capybara::Webkit::Connection do
redirected_connection.puts script.to_s.bytesize
redirected_connection.print script
sleep(0.5)
io.string.should include "hello world \n"
io.string.should =~ /hello world $/
end
it "returns the server port" do

View File

@ -2092,7 +2092,7 @@ describe Capybara::Webkit::Driver do
end
let(:driver) do
connection = Capybara::Webkit::Connection.new(:stdout => output)
connection = Capybara::Webkit::Connection.new(:stderr => output)
browser = Capybara::Webkit::Browser.new(connection)
Capybara::Webkit::Driver.new(AppRunner.app, :browser => browser)
end