2018-05-23 15:56:43 +02:00
|
|
|
ENV["RAILS_ENV"] ||= "test"
|
|
|
|
require_relative "../config/environment"
|
|
|
|
require "rails/test_help"
|
2018-05-23 10:32:04 +02:00
|
|
|
|
2018-05-29 22:32:25 +02:00
|
|
|
require "minitest/mock"
|
2018-06-02 14:46:32 +02:00
|
|
|
require_relative "test_mocks_helper"
|
2018-05-29 22:32:25 +02:00
|
|
|
|
2018-05-23 10:32:04 +02:00
|
|
|
class ActiveSupport::TestCase
|
|
|
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
|
|
|
fixtures :all
|
|
|
|
|
2018-05-23 17:59:28 +02:00
|
|
|
include Warden::Test::Helpers
|
|
|
|
Warden.test_mode!
|
|
|
|
|
2018-05-23 10:32:04 +02:00
|
|
|
# Add more helper methods to be used by all tests here...
|
2018-06-02 14:46:32 +02:00
|
|
|
include ActiveJob::TestHelper
|
2018-06-02 14:44:00 +02:00
|
|
|
include FactoryBot::Syntax::Methods
|
2018-06-02 14:46:32 +02:00
|
|
|
include TestMocksHelper
|
2018-05-23 10:32:04 +02:00
|
|
|
end
|
2018-05-23 17:59:28 +02:00
|
|
|
|
2018-06-02 14:46:32 +02:00
|
|
|
# Capybara configuration
|
2018-05-23 17:59:28 +02:00
|
|
|
Capybara.register_driver :headless_chrome do |app|
|
|
|
|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
|
|
|
"chromeOptions" => { args: %w[headless disable-gpu] + ["window-size=1280,800"] },
|
|
|
|
)
|
|
|
|
Capybara::Selenium::Driver.new app, browser: :chrome, desired_capabilities: capabilities
|
|
|
|
end
|
|
|
|
Capybara.save_path = Rails.root.join("tmp/capybara")
|
|
|
|
Capybara.javascript_driver = :headless_chrome
|
2018-06-02 14:46:32 +02:00
|
|
|
|
|
|
|
# Disable Open4 real system calls
|
|
|
|
require "open4"
|
|
|
|
require "errors"
|
|
|
|
module Open4
|
|
|
|
def popen4(*)
|
|
|
|
fail SystemCommandNotAllowedError,
|
|
|
|
"Real Open4 calls are disabled in test env. Use mock_system_command helper instead."
|
|
|
|
end
|
|
|
|
alias open4 popen4
|
|
|
|
alias pfork4 popen4
|
|
|
|
alias popen4ext popen4
|
|
|
|
|
|
|
|
module_function :open4
|
|
|
|
module_function :popen4
|
|
|
|
module_function :pfork4
|
|
|
|
module_function :popen4ext
|
|
|
|
end
|