2010-09-17 19:56:32 -04:00
|
|
|
require 'spec_helper'
|
2013-11-14 16:25:00 -05:00
|
|
|
require "selenium-webdriver"
|
|
|
|
|
|
|
|
Capybara.register_driver :selenium_focus do |app|
|
|
|
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
|
|
profile["focusmanager.testmode"] = true
|
|
|
|
Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
|
|
|
|
end
|
2009-11-14 04:44:46 -05:00
|
|
|
|
2012-10-30 09:32:47 -04:00
|
|
|
module TestSessions
|
2013-11-14 16:25:00 -05:00
|
|
|
Selenium = Capybara::Session.new(:selenium_focus, TestApp)
|
2012-10-30 09:32:47 -04:00
|
|
|
end
|
|
|
|
|
2013-11-14 12:43:36 -05:00
|
|
|
Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", :capybara_skip => [
|
2012-07-21 16:44:10 -04:00
|
|
|
:response_headers,
|
|
|
|
:status_code,
|
|
|
|
:trigger
|
|
|
|
]
|
|
|
|
|
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
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.driver).to 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
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.mode).to eq(:selenium_focus)
|
2009-11-14 04:44:46 -05:00
|
|
|
end
|
|
|
|
end
|
2009-12-11 16:40:23 -05:00
|
|
|
|
2014-01-17 02:57:06 -05:00
|
|
|
describe "#reset!" do
|
|
|
|
it "freshly reset session should not be touched" do
|
|
|
|
@session.instance_variable_set(:@touched, true)
|
|
|
|
@session.reset!
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session.instance_variable_get(:@touched)).to eq false
|
2014-01-17 02:57:06 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-13 07:15:44 -04:00
|
|
|
describe "exit codes" do
|
|
|
|
before do
|
|
|
|
@current_dir = Dir.getwd
|
2012-07-13 07:28:33 -04:00
|
|
|
Dir.chdir(File.join(File.dirname(__FILE__), '..'))
|
2012-07-13 07:15:44 -04:00
|
|
|
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`
|
2013-11-14 12:43:36 -05:00
|
|
|
expect($?.exitstatus).to be 1
|
2012-07-13 07:15:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should have return code 0 when running selenium_driver_rspec_success.rb" do
|
|
|
|
`rspec spec/fixtures/selenium_driver_rspec_success.rb`
|
2013-11-14 12:43:36 -05:00
|
|
|
expect($?.exitstatus).to be 0
|
2012-07-13 07:15:44 -04:00
|
|
|
end
|
|
|
|
end
|
2009-11-14 04:44:46 -05:00
|
|
|
end
|
|
|
|
end
|
2013-11-22 18:59:51 -05:00
|
|
|
|
|
|
|
describe Capybara::Selenium::Driver do
|
|
|
|
before do
|
|
|
|
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#quit' do
|
|
|
|
it "should reset browser when quit" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@driver.browser).to be
|
2013-11-22 18:59:51 -05:00
|
|
|
@driver.quit
|
|
|
|
#access instance variable directly so we don't create a new browser instance
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@driver.instance_variable_get(:@browser)).to be_nil
|
2013-11-22 18:59:51 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|