1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00
capybara-webkit/spec/browser_spec.rb
Hongli Lai (Phusion) dc49e5f875 Forward webkit_server's stdout to Ruby's stdout.
This allows console.log() messages to be visible, and prevents
large numbers of console.log() calls from filling up webkit_server's pipe
which would block the process.
2011-08-15 19:04:40 +02:00

35 lines
931 B
Ruby

require 'spec_helper'
require 'stringio'
require 'capybara/driver/webkit/browser'
describe Capybara::Driver::Webkit::Browser do
let(:browser) { Capybara::Driver::Webkit::Browser.new }
describe '#server_port' do
subject { browser.server_port }
it 'returns a valid port number' do
should be_a(Integer)
end
it 'returns a port in the allowed range' do
should be_between 0x400, 0xffff
end
end
context 'random port' do
it 'chooses a new port number for a new browser instance' do
new_browser = Capybara::Driver::Webkit::Browser.new
new_browser.server_port.should_not == browser.server_port
end
end
it 'forwards stdout to the given IO object' do
io = StringIO.new
new_browser = Capybara::Driver::Webkit::Browser.new(:stdout => io)
new_browser.execute_script('console.log("hello world")')
sleep(0.5)
io.string.should == "hello world\n"
end
end