Permalink
Browse files

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.
  • Loading branch information...
1 parent b06025b commit ea06a1b57fe7d86280578b6463202edd330721ee @mhoran mhoran committed Feb 2, 2013
Showing with 5 additions and 9 deletions.
  1. +1 −5 lib/capybara/webkit/connection.rb
  2. +3 −3 spec/connection_spec.rb
  3. +1 −1 spec/driver_spec.rb
@@ -12,7 +12,7 @@ class Connection
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 @@ def discover_port
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
@@ -18,9 +18,9 @@
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 @@
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
@@ -2092,7 +2092,7 @@ def which_for(character)
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

0 comments on commit ea06a1b

Please sign in to comment.