mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
ba37f78692
Swap from :skip to :capybara_skip since :skip is now used by RSpec 3 Add rspec 3 testing to beta gemfile
84 lines
2.2 KiB
Ruby
84 lines
2.2 KiB
Ruby
require 'spec_helper'
|
|
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
|
|
|
|
module TestSessions
|
|
Selenium = Capybara::Session.new(:selenium_focus, TestApp)
|
|
end
|
|
|
|
Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", :capybara_skip => [
|
|
:response_headers,
|
|
:status_code,
|
|
:trigger
|
|
]
|
|
|
|
describe Capybara::Session do
|
|
context 'with selenium driver' do
|
|
before do
|
|
@session = TestSessions::Selenium
|
|
end
|
|
|
|
describe '#driver' do
|
|
it "should be a selenium driver" do
|
|
expect(@session.driver).to be_an_instance_of(Capybara::Selenium::Driver)
|
|
end
|
|
end
|
|
|
|
describe '#mode' do
|
|
it "should remember the mode" do
|
|
expect(@session.mode).to eq(:selenium_focus)
|
|
end
|
|
end
|
|
|
|
describe "#reset!" do
|
|
it "freshly reset session should not be touched" do
|
|
@session.instance_variable_set(:@touched, true)
|
|
@session.reset!
|
|
expect(@session.instance_variable_get(:@touched)).to eq false
|
|
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`
|
|
expect($?.exitstatus).to 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`
|
|
expect($?.exitstatus).to be 0
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
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
|
|
expect(@driver.browser).to be
|
|
@driver.quit
|
|
#access instance variable directly so we don't create a new browser instance
|
|
expect(@driver.instance_variable_get(:@browser)).to be_nil
|
|
end
|
|
end
|
|
end
|
|
|
|
|