2009-11-04 17:00:05 -05:00
|
|
|
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2009-11-14 04:44:46 -05:00
|
|
|
require 'nokogiri'
|
|
|
|
|
2009-11-07 14:44:45 -05:00
|
|
|
shared_examples_for "session" do
|
2009-11-14 04:44:46 -05:00
|
|
|
def extract_results(session)
|
|
|
|
YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.text
|
|
|
|
end
|
2009-11-15 07:40:50 -05:00
|
|
|
|
2009-11-07 14:44:45 -05:00
|
|
|
describe '#app' do
|
|
|
|
it "should remember the application" do
|
|
|
|
@session.app.should == TestApp
|
2009-11-04 17:17:17 -05:00
|
|
|
end
|
2009-11-07 14:44:45 -05:00
|
|
|
end
|
2009-11-07 12:56:04 -05:00
|
|
|
|
2009-11-07 14:44:45 -05:00
|
|
|
describe '#visit' do
|
|
|
|
it "should fetch a response from the driver" do
|
|
|
|
@session.visit('/')
|
2009-11-14 04:44:46 -05:00
|
|
|
@session.body.should include('Hello world!')
|
2009-11-07 14:44:45 -05:00
|
|
|
@session.visit('/foo')
|
2009-11-14 04:44:46 -05:00
|
|
|
@session.body.should include('Another World')
|
2009-11-04 18:42:13 -05:00
|
|
|
end
|
2009-11-04 17:00:05 -05:00
|
|
|
end
|
2010-01-01 17:58:59 -05:00
|
|
|
|
|
|
|
describe '#body' do
|
|
|
|
it "should return the unmodified page body" do
|
|
|
|
@session.visit('/')
|
|
|
|
@session.body.should include('Hello world!')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#source' do
|
|
|
|
it "should return the unmodified page source" do
|
|
|
|
@session.visit('/')
|
|
|
|
@session.source.should include('Hello world!')
|
|
|
|
end
|
|
|
|
end
|
2009-12-17 12:41:05 -05:00
|
|
|
|
2009-12-15 14:58:51 -05:00
|
|
|
it_should_behave_like "all"
|
|
|
|
it_should_behave_like "attach_file"
|
|
|
|
it_should_behave_like "check"
|
2009-12-17 12:41:05 -05:00
|
|
|
it_should_behave_like "choose"
|
|
|
|
it_should_behave_like "click"
|
2009-12-15 14:58:51 -05:00
|
|
|
it_should_behave_like "click_button"
|
|
|
|
it_should_behave_like "click_link"
|
2009-12-17 12:41:05 -05:00
|
|
|
it_should_behave_like "fill_in"
|
2009-12-15 14:58:51 -05:00
|
|
|
it_should_behave_like "find_button"
|
|
|
|
it_should_behave_like "find_field"
|
|
|
|
it_should_behave_like "find_link"
|
2009-12-29 22:05:38 -05:00
|
|
|
it_should_behave_like "find_by_id"
|
2009-12-15 14:58:51 -05:00
|
|
|
it_should_behave_like "find"
|
2009-12-17 12:41:05 -05:00
|
|
|
it_should_behave_like "has_content"
|
|
|
|
it_should_behave_like "has_css"
|
2009-12-15 14:58:51 -05:00
|
|
|
it_should_behave_like "has_css"
|
|
|
|
it_should_behave_like "has_xpath"
|
2010-01-18 15:28:06 -05:00
|
|
|
it_should_behave_like "has_link"
|
2010-01-18 15:40:59 -05:00
|
|
|
it_should_behave_like "has_button"
|
2010-01-18 15:28:06 -05:00
|
|
|
it_should_behave_like "has_field"
|
2010-02-20 14:43:32 -05:00
|
|
|
it_should_behave_like "has_select"
|
2010-02-20 16:41:53 -05:00
|
|
|
it_should_behave_like "has_table"
|
2009-12-15 14:58:51 -05:00
|
|
|
it_should_behave_like "select"
|
2009-12-17 12:41:05 -05:00
|
|
|
it_should_behave_like "uncheck"
|
2010-02-19 15:37:46 -05:00
|
|
|
it_should_behave_like "unselect"
|
2009-12-31 14:04:38 -05:00
|
|
|
it_should_behave_like "locate"
|
2009-12-17 12:41:05 -05:00
|
|
|
it_should_behave_like "within"
|
|
|
|
it_should_behave_like "current_url"
|
2009-12-12 07:33:00 -05:00
|
|
|
end
|
|
|
|
|
2009-12-09 15:43:40 -05:00
|
|
|
|
2009-11-16 16:02:16 -05:00
|
|
|
describe Capybara::Session do
|
2009-11-07 14:44:45 -05:00
|
|
|
context 'with non-existant driver' do
|
2009-11-04 17:17:17 -05:00
|
|
|
it "should raise an error" do
|
|
|
|
running {
|
2009-11-16 16:02:16 -05:00
|
|
|
Capybara::Session.new(:quox, TestApp).driver
|
|
|
|
}.should raise_error(Capybara::DriverNotFoundError)
|
2009-11-04 17:00:05 -05:00
|
|
|
end
|
|
|
|
end
|
2009-11-07 09:36:58 -05:00
|
|
|
end
|