2010-09-17 23:56:32 +00:00
|
|
|
require 'spec_helper'
|
2009-11-07 19:44:45 +00:00
|
|
|
|
2009-11-16 21:02:16 +00:00
|
|
|
describe Capybara::Session do
|
2009-11-07 19:44:45 +00:00
|
|
|
context 'with rack test driver' do
|
|
|
|
before do
|
2010-09-07 16:16:19 +00:00
|
|
|
@session = TestSessions::RackTest
|
2009-11-07 19:44:45 +00:00
|
|
|
end
|
2009-12-12 12:33:00 +00:00
|
|
|
|
2009-11-07 19:44:45 +00:00
|
|
|
describe '#driver' do
|
|
|
|
it "should be a rack test driver" do
|
2011-04-05 15:42:12 +00:00
|
|
|
@session.driver.should be_an_instance_of(Capybara::RackTest::Driver)
|
2009-11-07 19:44:45 +00:00
|
|
|
end
|
|
|
|
end
|
2009-12-12 12:33:00 +00:00
|
|
|
|
2009-11-07 19:44:45 +00:00
|
|
|
describe '#mode' do
|
|
|
|
it "should remember the mode" do
|
|
|
|
@session.mode.should == :rack_test
|
|
|
|
end
|
|
|
|
end
|
2009-12-12 12:33:00 +00:00
|
|
|
|
2010-04-09 12:01:17 +00:00
|
|
|
describe '#click_link' do
|
|
|
|
it "should use data-method if available" do
|
|
|
|
@session.visit "/with_html"
|
|
|
|
@session.click_link "A link with data-method"
|
2011-04-05 15:42:12 +00:00
|
|
|
@session.body.should include('The requested object was deleted')
|
2010-04-09 12:01:17 +00:00
|
|
|
end
|
2011-08-30 09:20:29 +00:00
|
|
|
|
|
|
|
it "should not use data-method if option is false" do
|
|
|
|
@session.driver.options[:respect_data_method] = false
|
|
|
|
@session.visit "/with_html"
|
|
|
|
@session.click_link "A link with data-method"
|
|
|
|
@session.body.should include('Not deleted')
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
@session.driver.options[:respect_data_method] = true
|
|
|
|
end
|
2010-04-09 12:01:17 +00:00
|
|
|
end
|
|
|
|
|
2010-12-06 07:22:59 +00:00
|
|
|
describe "#attach_file" do
|
|
|
|
context "with multipart form" do
|
|
|
|
it "should submit an empty form-data section if no file is submitted" do
|
|
|
|
@session.visit("/form")
|
|
|
|
@session.click_button("Upload Empty")
|
|
|
|
@session.body.should include('Successfully ignored empty file field.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-11-07 19:44:45 +00:00
|
|
|
it_should_behave_like "session"
|
2009-12-12 20:56:32 +00:00
|
|
|
it_should_behave_like "session without javascript support"
|
2009-12-18 18:33:36 +00:00
|
|
|
it_should_behave_like "session with headers support"
|
2010-06-07 03:14:40 +00:00
|
|
|
it_should_behave_like "session with status code support"
|
2009-11-07 19:44:45 +00:00
|
|
|
end
|
|
|
|
end
|