1
0
mirror of https://github.com/danbee/my-images synced 2025-03-04 08:49:05 +00:00

Trying out headless Firefox instead of PhantomJS

This commit is contained in:
Daniel Barber 2018-09-12 21:38:40 -04:00
parent f134388fac
commit 543ef33e85
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
6 changed files with 27 additions and 15 deletions

View File

@ -29,9 +29,10 @@ end
group :test do group :test do
gem "capybara" gem "capybara"
gem "geckodriver-helper"
gem "launchy" gem "launchy"
gem "poltergeist"
gem "rspec-rails" gem "rspec-rails"
gem "selenium-webdriver"
gem "shoulda-matchers" gem "shoulda-matchers"
gem "webmock" gem "webmock"
end end

View File

@ -44,6 +44,8 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.2) addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 4.0)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (9.0.0) arel (9.0.0)
better_errors (2.5.0) better_errors (2.5.0)
coderay (>= 1.0.0) coderay (>= 1.0.0)
@ -59,7 +61,8 @@ GEM
rack (>= 1.6.0) rack (>= 1.6.0)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
xpath (~> 3.1) xpath (~> 3.1)
cliver (0.3.2) childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
coderay (1.1.2) coderay (1.1.2)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
crack (0.4.3) crack (0.4.3)
@ -87,6 +90,8 @@ GEM
faraday (0.12.2) faraday (0.12.2)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
ffi (1.9.25) ffi (1.9.25)
geckodriver-helper (0.21.0)
archive-zip (~> 0.7)
globalid (0.4.1) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
hashdiff (0.3.7) hashdiff (0.3.7)
@ -102,6 +107,7 @@ GEM
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
i18n (1.1.0) i18n (1.1.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
io-like (0.3.0)
jwt (1.5.6) jwt (1.5.6)
launchy (2.4.3) launchy (2.4.3)
addressable (~> 2.3) addressable (~> 2.3)
@ -139,10 +145,6 @@ GEM
oauth2 (~> 1.1) oauth2 (~> 1.1)
omniauth (~> 1.2) omniauth (~> 1.2)
pg (1.1.3) pg (1.1.3)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
pry (0.11.3) pry (0.11.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.9.0) method_source (~> 0.9.0)
@ -171,8 +173,6 @@ GEM
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4) rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2) loofah (~> 2.2, >= 2.2.2)
rails-ujs (0.1.0)
railties (>= 3.1)
railties (5.2.1) railties (5.2.1)
actionpack (= 5.2.1) actionpack (= 5.2.1)
activesupport (= 5.2.1) activesupport (= 5.2.1)
@ -201,6 +201,7 @@ GEM
rspec-mocks (~> 3.8.0) rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0) rspec-support (~> 3.8.0)
rspec-support (3.8.0) rspec-support (3.8.0)
rubyzip (1.2.2)
safe_yaml (1.0.4) safe_yaml (1.0.4)
sass (3.5.7) sass (3.5.7)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
@ -215,6 +216,9 @@ GEM
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
sdoc (1.0.0) sdoc (1.0.0)
rdoc (>= 5.0) rdoc (>= 5.0)
selenium-webdriver (3.14.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
shoulda-matchers (3.1.2) shoulda-matchers (3.1.2)
activesupport (>= 4.0.0) activesupport (>= 4.0.0)
simple_form (4.0.1) simple_form (4.0.1)
@ -261,18 +265,18 @@ DEPENDENCIES
delayed_job_active_record delayed_job_active_record
dotenv-rails dotenv-rails
dragonfly dragonfly
geckodriver-helper
http http
launchy launchy
omniauth-github omniauth-github
pg pg
poltergeist
pry pry
puma puma
rails (= 5.2.1) rails (= 5.2.1)
rails-ujs
rspec-rails rspec-rails
sass-rails sass-rails
sdoc sdoc
selenium-webdriver
shoulda-matchers shoulda-matchers
simple_form simple_form
uglifier uglifier

View File

@ -4,6 +4,7 @@ class TagsController < ApplicationController
def create def create
image = @current_user.images.find(params[:image_id]) image = @current_user.images.find(params[:image_id])
tag = params[:tag] tag = params[:tag]
if !image.tags.include?(tag) if !image.tags.include?(tag)
image.tags << tag image.tags << tag
image.save image.save

View File

@ -24,7 +24,7 @@ MyImages::Application.configure do
config.action_dispatch.show_exceptions = false config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment. # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = true
# Tell Action Mailer not to deliver emails to the real world. # Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the # The :test delivery method accumulates sent emails in the

View File

@ -18,7 +18,7 @@ feature "user manages image tags by visitng images show page" do
end end
end end
scenario "and can click the link to delete a tag" do scenario "and can click the link to delete a tag", js: true do
tags = ["one", "two"] tags = ["one", "two"]
user = User.create(uid: "123") user = User.create(uid: "123")
Image.create( Image.create(
@ -37,7 +37,7 @@ feature "user manages image tags by visitng images show page" do
expect(page).to_not have_content(tags.first) expect(page).to_not have_content(tags.first)
end end
scenario "user can add a tag to the list of tags" do scenario "user can add a tag to the list of tags", js: true do
tags = ["one", "two"] tags = ["one", "two"]
user = User.create(uid: "123") user = User.create(uid: "123")
new_tag = "new tag" new_tag = "new tag"

View File

@ -9,7 +9,6 @@ end
require "rspec/rails" require "rspec/rails"
require "shoulda/matchers" require "shoulda/matchers"
require "capybara/rspec" require "capybara/rspec"
require "capybara/poltergeist"
Dir[Rails.root.join("spec", "support", "**", "*.rb")].each { |f| require f } Dir[Rails.root.join("spec", "support", "**", "*.rb")].each { |f| require f }
@ -20,7 +19,14 @@ rescue ActiveRecord::PendingMigrationError => e
exit 1 exit 1
end end
Capybara.javascript_driver = :poltergeist Capybara.register_driver :firefox_headless do |app|
options = ::Selenium::WebDriver::Firefox::Options.new
options.args << "--headless"
Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
end
Capybara.javascript_driver = :firefox_headless
RSpec.configure do |config| RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures" config.fixture_path = "#{::Rails.root}/spec/fixtures"