internetee-registry/test/application_system_test_case.rb
Maciej Szlosarczyk 526a9ccd58
Change test structure to follow closer newer Rails 5 rules
* Create new class called ApplicationIntegrationTest, so we don't have
  to override ActionDispatch::IntegrationTest
* Move UI tests to inherit from ApplicationSystemTestCase
* Existing REST API or EPP tests inherit from
  ApplicationIntegrationTest.
* Move `require 'application_system_test_case'` at the end of
  `test_helper`

I don't particularly agree with the Rails' convention of treating UI
tests as system tests and API tests as integration tests, but I see no
benefit in actively fighting against it.
2018-07-27 09:36:27 +03:00

42 lines
1 KiB
Ruby

require 'test_helper'
require 'database_cleaner'
require 'selenium/webdriver'
ApplicationSystemTestCase = Class.new(ApplicationIntegrationTest)
class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
self.use_transactional_fixtures = false
DatabaseCleaner.strategy = :truncation
Capybara.register_driver(:chrome) do |_app|
options = ::Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--window-size=1400,1400')
Capybara::Selenium::Driver.new(Rails.application, browser: :chrome, options: options)
end
Capybara.register_server(:silent_puma) do |app, port, _host|
require 'rack/handler/puma'
Rack::Handler::Puma.run(app, Port: port, Threads: '0:2', Silent: true)
end
def setup
DatabaseCleaner.start
super
Capybara.current_driver = :chrome
Capybara.server = :silent_puma
end
def teardown
super
DatabaseCleaner.clean
end
end