Files
grecia/spec/rails_helper.rb
Javi Martín fed82b0024 Add a way to mark tests as consul/consul exclusive
Until now, when institutions made custom changes which made certain
tests obsolete, they didn't have a clear way to deal with the failing
tests. They would either:

1. Stop running the test suite
2. Run the test suite and get test failures 100% of the time
3. Comment the failing tests
4. Modify the failing tests in order to keep them in sync with the code

Solution 1 would be suicide from a maintenance perspective, although it
could work if only a couple of small custom changes were done.

Solution 2 would make it really hard to differenciate between "false
failures" and "real failures" when running the test suite.

Solution 3 would cause many conflicts when updating to a newer version
of Consul.

Solution 4 could make sense sometimes (big tests where only one line
needs to be changed), but it would also cause conflicts when updating
Consul.

So now, we're giving an alternative to solution 3 by making it easier to
exclude a test.

For tests that still need to be changed, when to use this solution
combined with a custom test and when to use solution 4 will have to be
decided on a per-case basis.
2022-01-03 13:33:37 +01:00

68 lines
1.6 KiB
Ruby

ENV["RAILS_ENV"] ||= "test"
if ENV["COVERALLS_REPO_TOKEN"]
require "coveralls"
Coveralls.wear!("rails")
end
require File.expand_path("../../config/environment", __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require "rspec/rails"
require "spec_helper"
require "custom_spec_helper"
require "capybara/rails"
require "capybara/rspec"
require "selenium/webdriver"
require "view_component/test_helpers"
module ViewComponent
module TestHelpers
def sign_in(user)
allow(controller).to receive(:current_user).and_return(user)
end
def within(...)
raise "`within` doesn't work in component tests. Use `page.find` instead."
end
end
end
RSpec.configure do |config|
config.include ViewComponent::TestHelpers, type: :component
end
Rails.application.load_tasks if Rake::Task.tasks.empty?
include Warden::Test::Helpers
Warden.test_mode!
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.infer_spec_type_from_file_location!
config.after do
Warden.test_reset!
end
end
FactoryBot.use_parent_strategy = false
Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
"goog:chromeOptions" => {
args: %W[headless no-sandbox window-size=1200,800 proxy-server=#{Capybara.app_host}:#{Capybara::Webmock.port_number}]
}
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: capabilities
)
end
Capybara.exact = true
Capybara.enable_aria_label = true
Capybara.disable_animation = true
OmniAuth.config.test_mode = true