1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/lib/capybara/spec/session.rb

79 lines
2.2 KiB
Ruby
Raw Normal View History

require 'capybara/spec/test_app'
require 'nokogiri'
2010-07-11 11:25:46 -04:00
Dir[File.dirname(__FILE__)+'/session/*'].each { |group| require group }
shared_examples_for "session" do
def extract_results(session)
YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.text
end
describe '#app' do
it "should remember the application" do
@session.app.should == TestApp
2009-11-04 17:17:17 -05:00
end
end
2009-11-07 12:56:04 -05:00
describe '#visit' do
it "should fetch a response from the driver" do
@session.visit('/')
@session.body.should include('Hello world!')
@session.visit('/foo')
@session.body.should include('Another World')
2009-11-04 18:42:13 -05:00
end
2009-11-04 17:00:05 -05:00
end
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
it_should_behave_like "all"
it_should_behave_like "attach_file"
it_should_behave_like "check"
it_should_behave_like "choose"
2010-07-19 14:42:49 -04:00
it_should_behave_like "click_link_or_button"
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_by_id"
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"
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"
it_should_behave_like "select"
it_should_behave_like "uncheck"
it_should_behave_like "unselect"
it_should_behave_like "within"
it_should_behave_like "current_url"
end
2009-11-16 16:02:16 -05:00
describe Capybara::Session do
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