Skip to content

Commit

Permalink
Merge branch 'migrate-to-cuprite' into test-migrate-to-cuprite-with-G…
Browse files Browse the repository at this point in the history
…H-Actions
  • Loading branch information
DeeDeeG committed Apr 28, 2024
2 parents 4decf8c + 85bf4c0 commit 6bc8baa
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 49 deletions.
16 changes: 1 addition & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,10 @@ FROM ruby:3.2.2-slim

# Add basic binaries
RUN apt-get update \
&& apt-get install -y curl g++ gcc libfontconfig libpq-dev make patch xz-utils \
&& apt-get install -y curl g++ gcc libfontconfig libpq-dev make patch xz-utils chromium \
# Clean up the apt cache
&& rm -rf /var/lib/apt/lists/*

# Download, extract and install PhantomJS from archive hosted at bitbucket
RUN curl -L https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O \
# Check the file's integrity against its known sha1sum
&& test "`sha1sum phantomjs-2.1.1-linux-x86_64.tar.bz2`" = "f8afc8a24eec34c2badccc93812879a3d6f2caf3 phantomjs-2.1.1-linux-x86_64.tar.bz2" || (echo "PhantomJS tarball SHA1sum did not match!" && exit 1) \
# Extract and clean up the PhantomJS archive
&& tar xf phantomjs-2.1.1-linux-x86_64.tar.bz2 && rm phantomjs-2.1.1-linux-x86_64.tar.bz2 \
# Install PhantomJS binary to /usr/local/bin
&& mv phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin \
# Clean up extra (un-needed) PhantomJS files
&& rm -rf phantomjs-2.1.1-linux-x86_64/

# Work around an issue with running "phantomjs --version"
ENV OPENSSL_CONF=/etc/ssl/

# Specify a major version of Node.js to download and install
ENV NODEJS_MAJOR_VERSION=16

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end
group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'poltergeist'
gem 'cuprite'
gem 'simplecov', '~> 0.22.0', require: false
gem 'webmock', '~> 3.12.1'
end
Expand Down
18 changes: 12 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
cliver (0.3.2)
coderay (1.1.3)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
Expand All @@ -136,6 +135,9 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
cuprite (0.15)
capybara (~> 3.0)
ferrum (~> 0.14.0)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0)
Expand Down Expand Up @@ -175,6 +177,11 @@ GEM
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
ferrum (0.14)
addressable (~> 2.5)
concurrent-ruby (~> 1.1)
webrick (~> 1.7)
websocket-driver (>= 0.6, < 0.8)
ffi (1.16.3)
formtastic (5.0.0)
actionpack (>= 6.0.0)
Expand Down Expand Up @@ -270,6 +277,8 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.7.0)
nokogiri (1.15.5-aarch64-linux)
racc (~> 1.4)
nokogiri (1.15.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.5-x86_64-linux)
Expand All @@ -284,10 +293,6 @@ GEM
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -464,6 +469,7 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
aarch64-linux
x86_64-darwin-19
x86_64-darwin-21
x86_64-linux
Expand All @@ -478,6 +484,7 @@ DEPENDENCIES
capybara
coffee-rails (~> 4.2)
country_select
cuprite
database_cleaner
devise (~> 4.8.1)
factory_bot_rails (~> 4.8.2)
Expand All @@ -497,7 +504,6 @@ DEPENDENCIES
pagy
pg
pg_search
poltergeist
pry
puma
rack-cors
Expand Down
25 changes: 6 additions & 19 deletions spec/support/locations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,12 @@ def locations
def mock_location(location_name)
location = locations[location_name.to_sym]
page.execute_script "
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Refuge.Library.Geocoder = (function() {
function Geocoder() {
this.getAddress = __bind(this.getAddress, this);
this.geocodeSearchString = __bind(this.geocodeSearchString, this);
}
Geocoder.prototype.getCurrentLocation = function() {
return jQuery.when(
{
latitude: #{location[:latitude]},
longitude: #{location[:longitude]}
});
};
return Geocoder;
})();
navigator.geolocation.getCurrentPosition = function(success, failure) {
success({ coords: {
latitude: #{location[:latitude]},
longitude: #{location[:longitude]}
}, timestamp: Date.now() });
}
"
end
# rubocop:enable Metrics/MethodLength
Expand Down
12 changes: 4 additions & 8 deletions spec/support/rspec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'capybara/poltergeist'
require 'capybara/cuprite'
require 'capybara/rspec'
require 'rspec/rails'
require 'json'
Expand All @@ -7,15 +7,11 @@

require_relative './locations'

Capybara.register_driver :poltergeist_debug do |app|
Capybara::Poltergeist::Driver.new(
app,
js_errors: false
)
Capybara.javascript_driver = :cuprite
Capybara.register_driver(:cuprite) do |app|
Capybara::Cuprite::Driver.new(app, window_size: [1200, 800], browser_options: { 'no-sandbox': nil })
end

Capybara.javascript_driver = :poltergeist_debug

WebMock.disable_net_connect!(allow_localhost: true)

RSpec.configure do |config|
Expand Down

0 comments on commit 6bc8baa

Please sign in to comment.