Skip to content

Commit

Permalink
move driver specific skipping/pending out of shared specs
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jul 5, 2018
1 parent 3b5f2c9 commit 44265e8
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 34 deletions.
1 change: 0 additions & 1 deletion lib/capybara/spec/session/accept_prompt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
end

it "should accept the prompt with a blank response when there is a default" do
pending "Geckodriver doesn't set a blank response currently" if marionette?(@session)
@session.accept_prompt with: '' do
@session.click_link('Open defaulted prompt')
end
Expand Down
1 change: 0 additions & 1 deletion lib/capybara/spec/session/current_url_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def visit_host_links
end

it "doesn't raise exception on a nil current_url" do
skip "Only makes sense when there is a real driver" unless @session.respond_to?(:driver)
allow(@session.driver).to receive(:current_url).and_return(nil)
@session.visit("/")
expect { @session.current_url }.not_to raise_exception
Expand Down
8 changes: 0 additions & 8 deletions lib/capybara/spec/session/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@
end

it "should allow multiple modifiers", requires: [:js] do
pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session)
@session.visit('with_js')
@session.find(:css, '#click-test').click(:control, :alt, :meta, :shift)
# Selenium with Chrome on OSX ctrl-click generates a right click so just verify all keys but not click type
Expand All @@ -403,10 +402,6 @@
end

describe '#double_click', requires: [:js] do
before do
pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session)
end

it "should double click an element" do
@session.visit('/with_js')
@session.find(:css, '#click-test').double_click
Expand Down Expand Up @@ -464,21 +459,18 @@
end

it "should send special characters" do
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if marionette?(@session)
@session.visit('/form')
@session.find(:css, '#address1_city').send_keys('Ocean', :space, 'sie', :left, 'd')
expect(@session.find(:css, '#address1_city').value).to eq 'Ocean side'
end

it "should allow for multiple simultaneous keys" do
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if marionette?(@session)
@session.visit('/form')
@session.find(:css, '#address1_city').send_keys([:shift, 'o'], 'ceanside')
expect(@session.find(:css, '#address1_city').value).to eq 'Oceanside'
end

it "should generate key events", requires: %i[send_keys js] do
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if marionette?(@session)
@session.visit('/with_js')
@session.find(:css, '#with-key-events').send_keys([:shift, 't'], [:shift, 'w'])
expect(@session.find(:css, '#key-events-output')).to have_text('keydown:16 keydown:84 keydown:16 keydown:87')
Expand Down
3 changes: 0 additions & 3 deletions lib/capybara/spec/session/refresh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
end

it "it reposts" do
if marionette?(@session) || edge?(@session) || ie?(@session)
skip "Firefox and Edge insist on prompting without providing a way to suppress"
end
@session.visit('/form')
@session.select('Sweden', from: 'form_region')
@session.click_button('awesome')
Expand Down
1 change: 0 additions & 1 deletion lib/capybara/spec/session/visit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
end

it "should fetch a response when sequentially visiting same destination with a target" do
skip "Chrome/chromedriver has an issue visiting URL with target after visiting same URL without target" if chrome_lt?(65.0, @session)
@session.visit('/form')
expect(@session).to have_css('#form_title')
@session.visit('/form#form_title')
Expand Down
5 changes: 3 additions & 2 deletions lib/capybara/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ def spec(name, *options, &block)
@specs << [name, options, block]
end

def run_specs(session, name, **options)
def run_specs(session, name, **options, &filter_block)
specs = @specs
RSpec.describe Capybara::Session, name, options do # rubocop:disable RSpec/EmptyExampleGroup
include Capybara::SpecHelper
include Capybara::RSpecMatchers
# rubocop:disable RSpec/ScatteredSetup
before do
before do |example|
@session = session
instance_exec(example, &filter_block) if filter_block
end

after do
Expand Down
7 changes: 6 additions & 1 deletion spec/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ class TestClass

Capybara::SpecHelper.run_specs TestClass.new, "DSL", capybara_skip: %i[
js modals screenshot frames windows send_keys server hover about_scheme psc download css
]
] do |example|
case example.metadata[:full_description]
when /doesn't raise exception on a nil current_url$/
skip "Only makes sense when there is a real driver"
end
end

RSpec.describe Capybara::DSL do
after do
Expand Down
7 changes: 6 additions & 1 deletion spec/selenium_spec_chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ module TestSessions

$stdout.puts `#{Selenium::WebDriver::Chrome.driver_path} --version` if ENV['CI']

Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_DRIVER.to_s, capybara_skip: skipped_tests
Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_DRIVER.to_s, capybara_skip: skipped_tests do |example|
case example.metadata[:description]
when /should fetch a response when sequentially visiting same destination with a target/
skip "Chrome/chromedriver has an issue visiting URL with target after visiting same URL without target" if chrome_lt?(65.0, @session)
end
end

RSpec.describe "Capybara::Session with chrome" do
include Capybara::SpecHelper
Expand Down
12 changes: 4 additions & 8 deletions spec/selenium_spec_chrome_remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ module TestSessions
# skip window tests when headless for now - closing a window not supported by chromedriver/chrome
skipped_tests << :windows if ENV['TRAVIS'] && (ENV['SKIP_WINDOW'] || ENV['HEADLESS'])

RSpec.configure do |config|
config.define_derived_metadata do |metadata|
case metadata[:full_description]
when /^Capybara::Session selenium_chrome_remote #attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files$/
metadata[:pending] = "Selenium with Remote Chrome doesn't support multiple file upload"
end
Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_REMOTE_DRIVER.to_s, capybara_skip: skipped_tests do |example|
case example.metadata[:full_description]
when 'Capybara::Session selenium_chrome_remote #attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files'
pending "Selenium with Remote Chrome doesn't support multiple file upload"
end
end

Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_REMOTE_DRIVER.to_s, capybara_skip: skipped_tests

RSpec.describe "Capybara::Session with remote Chrome" do
include Capybara::SpecHelper
include_examples "Capybara::Session", TestSessions::Chrome, CHROME_REMOTE_DRIVER
Expand Down
7 changes: 6 additions & 1 deletion spec/selenium_spec_edge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ module TestSessions

$stdout.puts `#{Selenium::WebDriver::Edge.driver_path} --version` if ENV['CI']

Capybara::SpecHelper.run_specs TestSessions::SeleniumEdge, "selenium", capybara_skip: skipped_tests
Capybara::SpecHelper.run_specs TestSessions::SeleniumEdge, "selenium", capybara_skip: skipped_tests do |example|
case example.metadata[:description]
when /#refresh it reposts$/
skip "Edge insists on prompting without providing a way to suppress"
end
end

RSpec.describe "Capybara::Session with Edge", capybara_skip: skipped_tests do
include Capybara::SpecHelper
Expand Down
25 changes: 20 additions & 5 deletions spec/selenium_spec_firefox_remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def ensure_selenium_running!
FIREFOX_REMOTE_DRIVER = :selenium_firefox_remote

module TestSessions
Firefox = Capybara::Session.new(FIREFOX_REMOTE_DRIVER, TestApp)
RemoteFirefox = Capybara::Session.new(FIREFOX_REMOTE_DRIVER, TestApp)
end

TestSessions::Firefox.driver.browser.file_detector = lambda do |args|
TestSessions::RemoteFirefox.driver.browser.file_detector = lambda do |args|
# args => ["/path/to/file"]
str = args.first.to_s
str if File.exist?(str)
Expand All @@ -58,12 +58,27 @@ module TestSessions
# skip window tests when headless for now - closing a window not supported by chromedriver/chrome
skipped_tests << :windows if ENV['TRAVIS'] && (ENV['SKIP_WINDOW'] || ENV['HEADLESS'])

Capybara::SpecHelper.run_specs TestSessions::Firefox, FIREFOX_REMOTE_DRIVER.to_s, capybara_skip: skipped_tests
Capybara::SpecHelper.run_specs TestSessions::RemoteFirefox, FIREFOX_REMOTE_DRIVER.to_s, capybara_skip: skipped_tests do |example|
case example.metadata[:full_description]
when 'Capybara::Session selenium_firefox_remote node #send_keys should generate key events',
'Capybara::Session selenium_firefox_remote node #send_keys should allow for multiple simultaneous keys',
'Capybara::Session selenium_firefox_remote node #send_keys should send special characters'
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters"
when 'Capybara::Session selenium_firefox_remote node #click should allow multiple modifiers'
pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session)
when /^Capybara::Session selenium node #double_click/
pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session)
when 'Capybara::Session selenium_firefox_remote #refresh it reposts'
skip 'Firefox insists on prompting without providing a way to suppress'
when 'Capybara::Session selenium_firefox_remote #accept_prompt should accept the prompt with a blank response when there is a default'
pending "Geckodriver doesn't set a blank response currently"
end
end

RSpec.describe "Capybara::Session with remote firefox" do
include Capybara::SpecHelper
include_examples "Capybara::Session", TestSessions::Firefox, FIREFOX_REMOTE_DRIVER
include_examples Capybara::RSpecMatchers, TestSessions::Firefox, FIREFOX_REMOTE_DRIVER
include_examples "Capybara::Session", TestSessions::RemoteFirefox, FIREFOX_REMOTE_DRIVER
include_examples Capybara::RSpecMatchers, TestSessions::RemoteFirefox, FIREFOX_REMOTE_DRIVER

it 'is considered to be firefox' do
expect(session.driver.send(:firefox?)).to be_truthy
Expand Down
7 changes: 6 additions & 1 deletion spec/selenium_spec_ie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ module TestSessions

$stdout.puts `#{Selenium::WebDriver::IE.driver_path} --version` if ENV['CI']

Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, "selenium", capybara_skip: skipped_tests
Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, "selenium", capybara_skip: skipped_tests do |example|
case example.metadata[:description]
when /#refresh it reposts$/
skip "Firefox and Edge insist on prompting without providing a way to suppress"
end
end

RSpec.describe "Capybara::Session with Internet Explorer", capybara_skip: skipped_tests do
include Capybara::SpecHelper
Expand Down
17 changes: 16 additions & 1 deletion spec/selenium_spec_marionette.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,22 @@ module TestSessions

$stdout.puts `#{Selenium::WebDriver::Firefox.driver_path} --version` if ENV['CI']

Capybara::SpecHelper.run_specs TestSessions::SeleniumMarionette, "selenium", capybara_skip: skipped_tests
Capybara::SpecHelper.run_specs TestSessions::SeleniumMarionette, "selenium", capybara_skip: skipped_tests do |example|
case example.metadata[:full_description]
when 'Capybara::Session selenium node #send_keys should generate key events',
'Capybara::Session selenium node #send_keys should allow for multiple simultaneous keys',
'Capybara::Session selenium node #send_keys should send special characters'
pending "selenium-webdriver/geckodriver doesn't support complex sets of characters"
when 'Capybara::Session selenium node #click should allow multiple modifiers'
pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session)
when /^Capybara::Session selenium node #double_click/
pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session)
when 'Capybara::Session selenium #refresh it reposts'
skip 'Firefox insists on prompting without providing a way to suppress'
when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default'
pending "Geckodriver doesn't set a blank response currently"
end
end

RSpec.describe "Capybara::Session with firefox" do # rubocop:disable RSpec/MultipleDescribes
include Capybara::SpecHelper
Expand Down

0 comments on commit 44265e8

Please sign in to comment.