2010-09-17 19:56:32 -04:00
|
|
|
require 'spec_helper'
|
2009-11-14 04:44:46 -05:00
|
|
|
|
2009-11-16 16:02:16 -05:00
|
|
|
describe Capybara::Session do
|
2009-11-14 04:44:46 -05:00
|
|
|
context 'with selenium driver' do
|
|
|
|
before do
|
2010-09-07 12:16:19 -04:00
|
|
|
@session = TestSessions::Selenium
|
2009-11-14 04:44:46 -05:00
|
|
|
end
|
2009-12-11 16:40:23 -05:00
|
|
|
|
2009-11-14 04:44:46 -05:00
|
|
|
describe '#driver' do
|
2009-12-11 16:40:23 -05:00
|
|
|
it "should be a selenium driver" do
|
2011-04-11 01:24:00 -04:00
|
|
|
@session.driver.should be_an_instance_of(Capybara::Selenium::Driver)
|
2009-11-14 04:44:46 -05:00
|
|
|
end
|
|
|
|
end
|
2009-12-11 16:40:23 -05:00
|
|
|
|
2009-11-14 04:44:46 -05:00
|
|
|
describe '#mode' do
|
|
|
|
it "should remember the mode" do
|
|
|
|
@session.mode.should == :selenium
|
|
|
|
end
|
|
|
|
end
|
2009-12-11 16:40:23 -05:00
|
|
|
|
2010-02-18 15:53:10 -05:00
|
|
|
it_should_behave_like "session"
|
2009-12-09 15:43:40 -05:00
|
|
|
it_should_behave_like "session with javascript support"
|
2012-07-10 00:50:15 -04:00
|
|
|
it_should_behave_like "session with screenshot support"
|
2012-07-13 06:59:57 -04:00
|
|
|
it_should_behave_like "session with frame support"
|
|
|
|
it_should_behave_like "session with window support"
|
2010-02-18 15:53:10 -05:00
|
|
|
it_should_behave_like "session without headers support"
|
2010-06-06 23:14:40 -04:00
|
|
|
it_should_behave_like "session without status code support"
|
2012-07-13 07:15:44 -04:00
|
|
|
|
|
|
|
unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
|
|
|
it "should not interfere with forking child processes" do
|
|
|
|
# Launch a browser, which registers the at_exit hook
|
|
|
|
browser = Capybara::Selenium::Driver.new(TestApp).browser
|
|
|
|
|
|
|
|
# Fork an unrelated child process. This should not run the code in the at_exit hook.
|
|
|
|
begin
|
|
|
|
pid = fork { "child" }
|
|
|
|
Process.wait2(pid)[1].exitstatus.should == 0
|
|
|
|
rescue NotImplementedError
|
|
|
|
# Fork unsupported (e.g. on JRuby)
|
|
|
|
end
|
|
|
|
|
|
|
|
browser.quit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "exit codes" do
|
|
|
|
before do
|
|
|
|
@current_dir = Dir.getwd
|
|
|
|
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..'))
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Dir.chdir(@current_dir)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should have return code 1 when running selenium_driver_rspec_failure.rb" do
|
|
|
|
`rspec spec/fixtures/selenium_driver_rspec_failure.rb`
|
|
|
|
$?.exitstatus.should be 1
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should have return code 0 when running selenium_driver_rspec_success.rb" do
|
|
|
|
`rspec spec/fixtures/selenium_driver_rspec_success.rb`
|
|
|
|
$?.exitstatus.should be 0
|
|
|
|
end
|
|
|
|
end
|
2009-11-14 04:44:46 -05:00
|
|
|
end
|
|
|
|
end
|