2009-11-04 23:00:05 +01:00
|
|
|
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2009-11-14 10:44:46 +01:00
|
|
|
require 'nokogiri'
|
|
|
|
|
2009-11-07 20:44:45 +01:00
|
|
|
shared_examples_for "session" do
|
2009-11-14 10:44:46 +01:00
|
|
|
def extract_results(session)
|
|
|
|
YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.text
|
|
|
|
end
|
2009-11-15 13:40:50 +01:00
|
|
|
|
2009-11-07 20:44:45 +01:00
|
|
|
describe '#app' do
|
|
|
|
it "should remember the application" do
|
|
|
|
@session.app.should == TestApp
|
2009-11-04 23:17:17 +01:00
|
|
|
end
|
2009-11-07 20:44:45 +01:00
|
|
|
end
|
2009-11-07 18:56:04 +01:00
|
|
|
|
2009-11-07 20:44:45 +01:00
|
|
|
describe '#visit' do
|
|
|
|
it "should fetch a response from the driver" do
|
|
|
|
@session.visit('/')
|
2009-11-14 10:44:46 +01:00
|
|
|
@session.body.should include('Hello world!')
|
2009-11-07 20:44:45 +01:00
|
|
|
@session.visit('/foo')
|
2009-11-14 10:44:46 +01:00
|
|
|
@session.body.should include('Another World')
|
2009-11-05 00:42:13 +01:00
|
|
|
end
|
2009-11-04 23:00:05 +01:00
|
|
|
end
|
2009-12-12 21:46:08 +01:00
|
|
|
|
2009-12-15 20:58:51 +01:00
|
|
|
it_should_behave_like "all"
|
|
|
|
it_should_behave_like "attach_file"
|
|
|
|
it_should_behave_like "check"
|
|
|
|
it_should_behave_like "choose"
|
|
|
|
it_should_behave_like "click"
|
|
|
|
it_should_behave_like "click_button"
|
|
|
|
it_should_behave_like "click_link"
|
|
|
|
it_should_behave_like "fill_in"
|
|
|
|
it_should_behave_like "find_button"
|
|
|
|
it_should_behave_like "find_field"
|
|
|
|
it_should_behave_like "find_link"
|
|
|
|
it_should_behave_like "find"
|
|
|
|
it_should_behave_like "has_content"
|
|
|
|
it_should_behave_like "has_css"
|
|
|
|
it_should_behave_like "has_css"
|
|
|
|
it_should_behave_like "has_xpath"
|
|
|
|
it_should_behave_like "select"
|
|
|
|
it_should_behave_like "uncheck"
|
|
|
|
it_should_behave_like "wait_for"
|
2009-12-16 13:25:12 +01:00
|
|
|
it_should_behave_like "within"
|
2009-12-12 13:33:00 +01:00
|
|
|
end
|
|
|
|
|
2009-12-09 21:43:40 +01:00
|
|
|
|
2009-11-16 22:02:16 +01:00
|
|
|
describe Capybara::Session do
|
2009-11-07 20:44:45 +01:00
|
|
|
context 'with non-existant driver' do
|
2009-11-04 23:17:17 +01:00
|
|
|
it "should raise an error" do
|
|
|
|
running {
|
2009-11-16 22:02:16 +01:00
|
|
|
Capybara::Session.new(:quox, TestApp).driver
|
|
|
|
}.should raise_error(Capybara::DriverNotFoundError)
|
2009-11-04 23:00:05 +01:00
|
|
|
end
|
|
|
|
end
|
2009-11-07 15:36:58 +01:00
|
|
|
end
|
2009-12-12 13:33:00 +01:00
|
|
|
|