2010-09-17 19:56:32 -04:00
|
|
|
require 'spec_helper'
|
2009-12-31 13:51:22 -05:00
|
|
|
|
|
|
|
describe Capybara do
|
2010-09-15 12:19:25 -04:00
|
|
|
|
2009-12-31 13:51:22 -05:00
|
|
|
describe 'default_wait_time' do
|
|
|
|
after do
|
2010-09-15 12:19:25 -04:00
|
|
|
Capybara.default_wait_time = @previous_default_time
|
2009-12-31 13:51:22 -05:00
|
|
|
end
|
2010-09-15 12:19:25 -04:00
|
|
|
|
2009-12-31 13:51:22 -05:00
|
|
|
it "should be changeable" do
|
2010-09-15 12:19:25 -04:00
|
|
|
@previous_default_time = Capybara.default_wait_time
|
2009-12-31 13:51:22 -05:00
|
|
|
Capybara.default_wait_time = 5
|
|
|
|
Capybara.default_wait_time.should == 5
|
|
|
|
end
|
|
|
|
end
|
2010-07-29 09:20:11 -04:00
|
|
|
|
|
|
|
describe '.register_driver' do
|
|
|
|
it "should add a new driver" do
|
|
|
|
Capybara.register_driver :schmoo do |app|
|
2011-04-08 11:14:05 -04:00
|
|
|
Capybara::RackTest::Driver.new(app)
|
2010-07-29 09:20:11 -04:00
|
|
|
end
|
|
|
|
session = Capybara::Session.new(:schmoo, TestApp)
|
|
|
|
session.visit('/')
|
|
|
|
session.body.should include("Hello world!")
|
|
|
|
end
|
|
|
|
end
|
2010-09-15 12:19:25 -04:00
|
|
|
|
2010-10-27 22:53:59 -04:00
|
|
|
describe ".server" do
|
|
|
|
after do
|
|
|
|
Capybara.server {|app, port| Capybara.run_default_server(app, port)}
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should default to a proc that calls run_default_server" do
|
|
|
|
mock_app = mock('app')
|
|
|
|
Capybara.should_receive(:run_default_server).with(mock_app, 8000)
|
|
|
|
Capybara.server.call(mock_app, 8000)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return a custom server proc" do
|
|
|
|
server = lambda {|app, port|}
|
|
|
|
Capybara.server(&server)
|
|
|
|
Capybara.server.should == server
|
|
|
|
end
|
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-10-27 22:53:59 -04:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
describe Capybara::Session do
|
|
|
|
context 'with non-existant driver' do
|
|
|
|
it "should raise an error" do
|
2012-10-30 09:26:19 -04:00
|
|
|
expect {
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::Session.new(:quox, TestApp).driver
|
2012-10-30 09:26:19 -04:00
|
|
|
}.to raise_error(Capybara::DriverNotFoundError)
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
end
|
2010-07-29 09:20:11 -04:00
|
|
|
end
|