diff --git a/lib/billy/browsers/capybara.rb b/lib/billy/browsers/capybara.rb index 4394d28..44a90d2 100644 --- a/lib/billy/browsers/capybara.rb +++ b/lib/billy/browsers/capybara.rb @@ -48,24 +48,17 @@ def self.register_webkit_driver def self.register_selenium_driver ::Capybara.register_driver :selenium_billy do |app| - capabilities = [ - build_selenium_options_for_firefox, - Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true) - ] + options = build_selenium_options_for_firefox - ::Capybara::Selenium::Driver.new(app, capabilities: capabilities) + ::Capybara::Selenium::Driver.new(app, options: options) end ::Capybara.register_driver :selenium_headless_billy do |app| options = build_selenium_options_for_firefox.tap do |opts| opts.add_argument '-headless' end - capabilities = [ - options, - Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true) - ] - ::Capybara::Selenium::Driver.new(app, capabilities: capabilities) + ::Capybara::Selenium::Driver.new(app, options: options) end ::Capybara.register_driver :selenium_chrome_billy do |app| diff --git a/spec/lib/billy/browsers/capybara_spec.rb b/spec/lib/billy/browsers/capybara_spec.rb index 98925f5..32f55a5 100644 --- a/spec/lib/billy/browsers/capybara_spec.rb +++ b/spec/lib/billy/browsers/capybara_spec.rb @@ -1,28 +1,61 @@ require 'spec_helper' describe 'Capybara drivers', type: :feature, js: true do - it 'allows HTTPS calls' do - proxy.stub('https://blog.howmanyleft.co.uk:443/api/read/json').and_return( - jsonp: { - posts: [ - { - 'regular-title' => 'News Item 1', - 'url-with-slug' => 'http://example.com/news/1', - 'regular-body' => 'News item 1 content here' - }, - { - 'regular-title' => 'News Item 2', - 'url-with-slug' => 'http://example.com/news/2', - 'regular-body' => 'News item 2 content here' - } - ] - }) - - visit '/tumblr_api_https.html' - - expect(page).to have_link('News Item 1', href: 'http://example.com/news/1') - expect(page).to have_content('News item 1 content here') - expect(page).to have_link('News Item 2', href: 'http://example.com/news/2') - expect(page).to have_content('News item 2 content here') + context "using selenium chrome headless billy driver" do + before { Capybara.current_driver = :selenium_chrome_headless_billy } + + it 'allows HTTPS calls' do + proxy.stub('https://blog.howmanyleft.co.uk:443/api/read/json').and_return( + jsonp: { + posts: [ + { + 'regular-title' => 'News Item 1', + 'url-with-slug' => 'http://example.com/news/1', + 'regular-body' => 'News item 1 content here' + }, + { + 'regular-title' => 'News Item 2', + 'url-with-slug' => 'http://example.com/news/2', + 'regular-body' => 'News item 2 content here' + } + ] + }) + + visit '/tumblr_api_https.html' + + expect(page).to have_link('News Item 1', href: 'http://example.com/news/1') + expect(page).to have_content('News item 1 content here') + expect(page).to have_link('News Item 2', href: 'http://example.com/news/2') + expect(page).to have_content('News item 2 content here') + end + end + + context "using selenium headless billy driver" do + before { Capybara.current_driver = :selenium_headless_billy } + + it 'allows HTTPS calls' do + proxy.stub('https://blog.howmanyleft.co.uk:443/api/read/json').and_return( + jsonp: { + posts: [ + { + 'regular-title' => 'News Item 1', + 'url-with-slug' => 'http://example.com/news/1', + 'regular-body' => 'News item 1 content here' + }, + { + 'regular-title' => 'News Item 2', + 'url-with-slug' => 'http://example.com/news/2', + 'regular-body' => 'News item 2 content here' + } + ] + }) + + visit '/tumblr_api_https.html' + + expect(page).to have_link('News Item 1', href: 'http://example.com/news/1') + expect(page).to have_content('News item 1 content here') + expect(page).to have_link('News Item 2', href: 'http://example.com/news/2') + expect(page).to have_content('News item 2 content here') + end end end