Skip to content

Commit cf82a88

Browse files
committed
Manage Selenium drivers automatically
1 parent ceae954 commit cf82a88

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ group :test do
3434
gem "selenium-webdriver"
3535
gem "shoulda-matchers"
3636
gem "timecop"
37+
gem "webdrivers"
3738
gem "webmock"
3839
gem "xpath", "3.2.0"
3940
end

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ GEM
304304
unicorn (6.0.0)
305305
kgio (~> 2.6)
306306
raindrops (~> 0.7)
307+
webdrivers (5.0.0)
308+
nokogiri (~> 1.6)
309+
rubyzip (>= 1.3.0)
310+
selenium-webdriver (~> 4.0)
307311
webmock (3.14.0)
308312
addressable (>= 2.8.0)
309313
crack (>= 0.3.2)
@@ -352,6 +356,7 @@ DEPENDENCIES
352356
timecop
353357
uglifier
354358
unicorn
359+
webdrivers
355360
webmock
356361
xpath (= 3.2.0)
357362
yard

bin/setup

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ bundle exec rake db:setup dev:prime
2323
# Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
2424
mkdir -p .git/safe
2525

26-
if ! command -v chromedriver > /dev/null; then
27-
printf 'chromedriver is not installed.\n'
28-
printf 'See https://chromedriver.chromium.org for install instructions.\n'
29-
fi
30-
3126
# Only if this isn't CI
3227
# if [ -z "$CI" ]; then
3328
# fi

spec/spec_helper.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require "webmock/rspec"
2-
31
# http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
42
RSpec.configure do |config|
53
config.expect_with :rspec do |expectations|
@@ -12,5 +10,3 @@
1210

1311
config.order = :random
1412
end
15-
16-
WebMock.disable_net_connect!(allow_localhost: true)

spec/support/webmock.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require "webmock/rspec"
2+
3+
# Allow downloading webdrivers for Selenium
4+
driver_hosts = Webdrivers::Common.subclasses.
5+
map { |driver| URI(driver.base_url).host }
6+
7+
# Downloading the Firefox driver involves a redirect
8+
driver_hosts += ["github-releases.githubusercontent.com"]
9+
10+
# Additionally, avoid conflict with Selenium (localhost)
11+
WebMock.disable_net_connect!(allow_localhost: true, allow: driver_hosts)

0 commit comments

Comments
 (0)