Skip to content

Commit

Permalink
Migrate to use System Tests
Browse files Browse the repository at this point in the history
This is a WIP Pull Request to kick the tires on CI
  • Loading branch information
seanpdoyle committed Nov 22, 2019
1 parent d652809 commit d9066c4
Show file tree
Hide file tree
Showing 28 changed files with 52 additions and 53 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ end
group :test do
gem "ammeter"
gem "capybara", "3.29.0"
gem "database_cleaner"
gem "capybara-selenium"
gem "formulaic"
gem "launchy"
gem "poltergeist"
gem "pundit"
gem "selenium-webdriver"
gem "shoulda-matchers"
gem "timecop"
gem "webmock"
gem "webdrivers"
gem "xpath", "3.2.0"
end

Expand Down
26 changes: 15 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
cliver (0.3.2)
capybara-selenium (0.0.6)
capybara
selenium-webdriver
childprocess (3.0.0)
coderay (1.1.2)
concurrent-ruby (1.1.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.5)
database_cleaner (1.7.0)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
diff-lcs (1.3)
Expand Down Expand Up @@ -149,10 +151,6 @@ GEM
parser (2.6.2.1)
ast (~> 2.4.0)
pg (1.1.4)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand Down Expand Up @@ -201,6 +199,7 @@ GEM
rspec-mocks (~> 3.8)
rspec-support (~> 3.8)
rspec-support (3.9.0)
rubyzip (2.0.0)
safe_yaml (1.0.5)
sassc (2.2.0)
ffi (~> 1.9)
Expand All @@ -211,6 +210,9 @@ GEM
sprockets-rails
tilt
selectize-rails (0.12.6)
selenium-webdriver (3.142.6)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sentry-raven (2.12.3)
faraday (>= 0.7.6, < 1.0)
shoulda-matchers (4.1.2)
Expand All @@ -236,13 +238,14 @@ GEM
unicorn (5.5.1)
kgio (~> 2.6)
raindrops (~> 0.7)
webdrivers (4.1.3)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
webmock (3.7.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.2.0)
Expand All @@ -260,7 +263,7 @@ DEPENDENCIES
bundler-audit
byebug
capybara (= 3.29.0)
database_cleaner
capybara-selenium
dotenv-rails
factory_bot_rails
faker
Expand All @@ -269,17 +272,18 @@ DEPENDENCIES
i18n-tasks (= 0.9.29)
launchy
pg
poltergeist
pry-rails
pundit
rack-timeout
redcarpet
rspec-rails
selenium-webdriver
sentry-raven
shoulda-matchers
timecop
uglifier
unicorn
webdrivers
webmock
xpath (= 3.2.0)

Expand Down
5 changes: 0 additions & 5 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ if ! command -v foreman > /dev/null; then
printf 'See https://github.com/ddollar/foreman for install instructions.\n'
fi

if ! command -v phantomjs > /dev/null; then
printf 'Phantomjs is not installed.\n'
printf 'See http://phantomjs.org/download.html for install instructions.\n'
fi

# Only if this isn't CI
# if [ -z "$CI" ]; then
# fi
Expand Down
14 changes: 3 additions & 11 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@

require "rspec/rails"
require "shoulda/matchers"
require "capybara/poltergeist"

Dir[Rails.root.join("../../spec/support/**/*.rb")].each { |file| require file }

require "factories"

module Features
# Extend this module in spec/support/features/*.rb
module SystemHelpers
# Extend this module in spec/support/system_helpers/*.rb
include Formulaic::Dsl
end

RSpec.configure do |config|
config.include Features, type: :feature
config.include SystemHelpers, type: :system
config.include DashboardHelpers
config.include ControllerHelpers
config.infer_base_class_for_anonymous_controllers = false
Expand All @@ -31,10 +30,3 @@ module Features
end

ActiveRecord::Migration.maintain_test_schema!
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
options = { phantomjs_options: ["--load-images=no"] }
Capybara::Poltergeist::Driver.new(app, options)
end

Capybara.server = :webrick
28 changes: 28 additions & 0 deletions spec/support/chromedriver.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "selenium/webdriver"

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end

Capybara.register_driver :headless_chrome do |app|
options = ::Selenium::WebDriver::Chrome::Options.new
options.headless!
options.add_argument "--window-size=1680,1050"

Capybara::Selenium::Driver.new app,
browser: :chrome,
options: options
end

Capybara.server = :webrick
Capybara.javascript_driver = :headless_chrome

RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by :rack_test
end

config.before(:each, type: :system, js: true) do
driven_by Capybara.javascript_driver
end
end
21 changes: 0 additions & 21 deletions spec/support/database_cleaner.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Features
module SystemHelpers
def have_flash(text, options = {})
options.reverse_merge!(type: :notice)
have_css(".flash-#{options[:type]}", text: text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Features
module SystemHelpers
def have_header(title)
have_css("h1", text: title)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Features
module SystemHelpers
def click_row_for(model)
within(row_css_for(model)) do
all(clickable_table_elements).first.click
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d9066c4

Please sign in to comment.