diff --git a/Gemfile b/Gemfile index 8773b76d58..9d1b67c480 100644 --- a/Gemfile +++ b/Gemfile @@ -115,9 +115,10 @@ end group :test do gem "capybara" + gem "chromedriver-helper" gem "database_rewinder" gem "factory_bot_rails" - gem "poltergeist" + gem "selenium-webdriver" gem "simplecov", require: false gem "timecop" end diff --git a/Gemfile.lock b/Gemfile.lock index 2b708b202a..60b7840336 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,6 +72,8 @@ GEM annotate (2.7.4) activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 13.0) + archive-zip (0.11.0) + io-like (~> 0.3.0) arel (9.0.0) ast (2.4.0) awesome_print (1.8.0) @@ -121,11 +123,15 @@ GEM rack (>= 1.6.0) rack-test (>= 0.6.3) xpath (~> 3.1) + childprocess (0.9.0) + ffi (~> 1.0, >= 1.0.11) + chromedriver-helper (1.2.0) + archive-zip (~> 0.10) + nokogiri (~> 1.8) chunky_png (1.3.10) cld (0.7.0) ffi climate_control (0.2.0) - cliver (0.3.2) cocaine (0.6.0) terrapin (= 0.6.0) coderay (1.1.2) @@ -264,6 +270,7 @@ GEM imgix (~> 1.1, >= 1.1.0) impressionist (1.6.1) nokogiri (~> 1) + io-like (0.3.0) jaro_winkler (1.5.1) jb (0.5.0) multi_json @@ -380,10 +387,6 @@ GEM parser (2.5.1.2) ast (~> 2.4.0) pg (1.0.0) - poltergeist (1.18.1) - capybara (>= 2.1, < 4) - cliver (~> 0.3.1) - websocket-driver (>= 0.2.0) polyamorous (1.3.3) activerecord (>= 3.0) powerpack (0.1.2) @@ -497,6 +500,7 @@ GEM ruby_dep (1.5.0) ruby_identicon (0.0.5) chunky_png (~> 1.3.5) + rubyzip (1.2.1) sass (3.5.6) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -505,6 +509,9 @@ GEM scss_lint (0.57.0) rake (>= 0.9, < 13) sass (~> 3.5.5) + selenium-webdriver (3.13.0) + childprocess (~> 0.5) + rubyzip (~> 1.2) sentry-raven (2.7.4) faraday (>= 0.7.6, < 1.0) simple_oauth (0.3.1) @@ -612,6 +619,7 @@ DEPENDENCIES bullet by_star capybara + chromedriver-helper cld commonmarker counter_culture @@ -663,7 +671,6 @@ DEPENDENCIES omniauth-twitter paperclip pg - poltergeist pry pry-alias pry-byebug @@ -686,6 +693,7 @@ DEPENDENCIES rubocop ruby_identicon scss_lint + selenium-webdriver sentry-raven simplecov sitemap_generator diff --git a/README.md b/README.md index 2e005ae493..5d31ee35aa 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ To run Annict on a local machine, you need to have the following dependencies in * Ruby 2.5 * PostgreSQL 10.4 * ImageMagick -* PhantomJS - * For tests +* ChromeDriver #### Running the app diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d236c2e3d4..faddc9078a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,6 @@ require File.expand_path("../../config/environment", __FILE__) require "rspec/rails" -require "capybara/poltergeist" require "capybara/rails" require "capybara/rspec" @@ -48,4 +47,8 @@ # the seed, which is printed after each run. # --seed 1234 config.order = "random" + + config.before(:each, type: :system) do + driven_by :selenium_chrome_headless + end end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb deleted file mode 100644 index 29a97d8369..0000000000 --- a/spec/support/capybara.rb +++ /dev/null @@ -1,35 +0,0 @@ -Capybara.default_max_wait_time = 8 # Seconds to wait before timeout error. Default is 2 - -# Register slightly larger than default window size... -Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new(app, { - debug: false, # change this to true to troubleshoot - window_size: [1300, 1000], # this can affect dynamic layout - timeout: 60, - js_errors: false - }) -end - -Capybara.javascript_driver = :poltergeist - -## -# スクショ画像を作成するためのメソッド。`tmp/render` 以下に画像が保存されます。 -# 注意: このメソッドを使用するときは、`js` オプションを `context` メソッドなどに指定してください。 -# -# 例: -# describe '#index' do -# context 'うまくいってるとき', js: true do -# render_page('すくしょ') -# end -# end -# -def render_page(name) - png_name = name.strip.gsub(/\W+/, '-') - path = File.join('tmp/render', "#{png_name}.png") - save_screenshot(path) -end - -# HTML形式でページを保存する `save_and_open_page` メソッドのショートカット -def save! - save_and_open_page -end diff --git a/spec/features/comments_spec.rb b/spec/system/comments_spec.rb similarity index 100% rename from spec/features/comments_spec.rb rename to spec/system/comments_spec.rb diff --git a/spec/features/home_spec.rb b/spec/system/home_spec.rb similarity index 100% rename from spec/features/home_spec.rb rename to spec/system/home_spec.rb