Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from PhantomJS to headless Chrome #101

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AllCops:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used Rubocop some time ago, but didn't remember I'm still using it.

It's good to have it, I think. But line length and stuff sometimes seems a pain in the ass, especially in specs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True but for some blocks as it, scenario and so on you can disable the line length. Feel free to change it as soon as it disturbs you (not tested):

LineLength:
  Enabled: true
  Max: 160
  ExcludedMethods:
    - describe
    - context
    - scenario
    - it
    - feature
Metrics/BlockLength:
  ExcludedMethods:
    - describe
    - context
    - scenario
    - it
    - feature

Exclude:
- db/schema.rb
FrozenStringLiteralComment:
Enabled: false
LineLength:
Enabled: true
Max: 160
Rails:
Enabled: true
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ rvm:
- 2.4.1
bundler_args: --without development
cache: bundler
sudo: required
addons:
apt_packages:
- pandoc
code_climate:
repo_token: 243e5ab59244b7a1d3fb97d56bfe9961307ad558cb4a7cbeec3c85104e9ee11b
chrome: stable
before_install:
- export TZ=Europe/Zurich
- mysql -e 'CREATE DATABASE base_test'
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting stuff. Could you explain a bit more (or give a link)?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, Chromedriver isn't found on Travis. Any idea how to fix?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope I had not the time atm.

Copy link
Collaborator

@gurix gurix Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/flavorjones/chromedriver-helper seems to install it properly. Hint came from http://quyetbui.info/chrome-headless-capybara-on-travis-ci/. But i am not sure if i.e google-chrome-stable --headless --disable-gpu ... and the gem capybara-selenium ir really needed in this setting.


before_script:
- cp config/secrets.travis.yml config/secrets.yml
- export DISPLAY=:99.0 && sh -e /etc/init.d/xvfb start && sleep 3

script:
- RAILS_ENV=test bundle exec rails db:create
- RAILS_ENV=test bundle exec rails db:migrate
Expand Down
13 changes: 5 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ group :development, :test do
gem 'rspec'
gem 'rspec-rails' # RSpec for Rails

gem 'sqlite3' # Use SQLite as the database for Active Record
gem 'capybara' # Capybara helps you test web applications by simulating how a real user would interact with your app.

# Data generation
gem 'factory_bot_rails' # Test data generator
Expand Down Expand Up @@ -141,9 +141,9 @@ group :development do

gem 'rubocop', require: false # A robust Ruby code analyzer, based on the community Ruby style guide

gem 'capybara', '>=2.2.0.beta' # Acceptance test framework for web applications
gem 'capybara-selenium' # Acceptance test framework for web applications

gem 'rails-footnotes' # Every Rails page has footnotes that gives information about your application
gem 'rack-mini-profiler' # Profiler for your development and production Ruby rack apps

gem 'mina', require: false # Really fast deployer and server automation tool

Expand All @@ -163,12 +163,9 @@ group :test do

gem 'database_cleaner' # Resets test database after each test

# Capybara - Headless, JavaScript-executing browser for Selenium
gem 'poltergeist', github: 'teampoltergeist/poltergeist' # PhantomJS driver for Capybara, see https://github.com/teampoltergeist/poltergeist/pull/913
gem 'launchy' # Use `save_and_open_page` in request tests to automatically open a browser
gem 'selenium-webdriver' # Selenium webdriver (needed to use Chrome driver)
gem 'selenium-webdriver' # Selenium webdriver (needed to use Chrome driver)

gem 'capybara-screenshot' # Automatically save screen shots when a scenario fails
gem 'chromedriver-helper' # Easy installation and use of chromedriver, the Chromium project's selenium webdriver adapter.

gem 'i18n-tasks' # Manage translation and localization with static analysis

Expand Down
Loading