Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit ea06a1b57fe7d86280578b6463202edd330721ee 1 parent b06025b
@mhoran mhoran authored
View
6 lib/capybara/webkit/connection.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
@@ -75,10 +75,6 @@ def discover_port
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)
end
end
View
6 spec/connection_spec.rb
@@ -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
2  spec/driver_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.