2011-07-08 09:17:38 -04:00
|
|
|
require 'spec_helper'
|
2011-08-15 12:17:14 -04:00
|
|
|
require 'stringio'
|
2011-07-06 08:30:52 -04:00
|
|
|
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
|
2011-07-06 08:36:30 -04:00
|
|
|
should be_between 0x400, 0xffff
|
2011-07-06 08:30:52 -04:00
|
|
|
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
|
2011-08-15 12:17:14 -04:00
|
|
|
|
|
|
|
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
|
2011-07-06 08:30:52 -04:00
|
|
|
|
|
|
|
end
|