2015-08-10 11:05:06 +02:00
|
|
|
|
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
|
|
|
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
2020-03-25 15:04:48 +01:00
|
|
|
|
# The `.rspec` file contains `--require rails_helper`, which requires spec_helper.rb,
|
|
|
|
|
# causing this file to always be loaded, without a need to explicitly require it in any
|
2015-08-10 11:05:06 +02:00
|
|
|
|
# files.
|
|
|
|
|
#
|
|
|
|
|
# Given that it is always loaded, you are encouraged to keep this file as
|
|
|
|
|
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
|
|
|
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
|
|
|
# individual file that may not need all of that loaded. Instead, consider making
|
|
|
|
|
# a separate helper file that requires the additional dependencies and performs
|
|
|
|
|
# the additional setup, and require it from the spec files that actually need
|
|
|
|
|
# it.
|
|
|
|
|
#
|
|
|
|
|
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
|
|
|
# users commonly want.
|
|
|
|
|
#
|
|
|
|
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
2024-04-22 15:02:35 +02:00
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
require 'simplecov' # see config in .simplecov file
|
|
|
|
|
|
2022-10-10 09:41:33 +02:00
|
|
|
|
require 'rspec/retry'
|
2015-08-10 11:05:06 +02:00
|
|
|
|
|
2023-03-03 14:16:15 +01:00
|
|
|
|
SECURE_PASSWORD = 'my-s3cure-p4ssword'
|
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
|
RSpec.configure do |config|
|
|
|
|
|
config.filter_run_excluding disable: true
|
|
|
|
|
config.color = true
|
|
|
|
|
config.tty = true
|
|
|
|
|
|
2021-03-08 10:35:47 +01:00
|
|
|
|
config.example_status_persistence_file_path = 'failing_specs.txt'
|
2017-10-06 10:17:07 +02:00
|
|
|
|
config.run_all_when_everything_filtered = true
|
2017-10-05 14:47:15 +02:00
|
|
|
|
config.filter_run :focus => true
|
2016-02-22 19:42:47 +01:00
|
|
|
|
|
2015-08-20 17:30:17 +02:00
|
|
|
|
config.order = 'random'
|
2018-07-25 19:35:18 +02:00
|
|
|
|
# Fix the seed not changing between runs when using Spring
|
|
|
|
|
# See https://github.com/rails/spring/issues/113
|
|
|
|
|
config.seed = srand % 0xFFFF unless ARGV.any? { |arg| arg =~ /seed/ || arg =~ /rand:/ }
|
2015-08-10 11:05:06 +02:00
|
|
|
|
|
2019-03-06 14:42:27 +01:00
|
|
|
|
RSpec::Matchers.define :have_same_attributes_as do |expected, options|
|
2016-06-15 11:34:05 +02:00
|
|
|
|
match do |actual|
|
|
|
|
|
ignored = [:id, :procedure_id, :updated_at, :created_at]
|
2019-03-06 14:42:27 +01:00
|
|
|
|
if options.present? && options[:except]
|
|
|
|
|
ignored = ignored + options[:except]
|
|
|
|
|
end
|
2016-06-15 11:34:05 +02:00
|
|
|
|
actual.attributes.with_indifferent_access.except(*ignored) == expected.attributes.with_indifferent_access.except(*ignored)
|
|
|
|
|
end
|
|
|
|
|
end
|
2019-06-03 15:47:56 +02:00
|
|
|
|
|
|
|
|
|
# Asserts that a given select element exists in the page,
|
|
|
|
|
# and that the option(s) with the given value(s) are selected.
|
|
|
|
|
#
|
|
|
|
|
# Usage: expect(page).to have_selected_value('Country', selected: 'Australia')
|
|
|
|
|
#
|
|
|
|
|
# For large lists, this is much faster than `have_select(location, selected: value)`,
|
|
|
|
|
# as it doesn’t check that every other options are not selected.
|
|
|
|
|
RSpec::Matchers.define(:have_selected_value) do |select_locator, options|
|
|
|
|
|
match do |page|
|
|
|
|
|
values = options[:selected].is_a?(String) ? [options[:selected]] : options[:selected]
|
|
|
|
|
|
|
|
|
|
select_element = page.first(:select, select_locator)
|
|
|
|
|
select_element && values.all? do |value|
|
|
|
|
|
select_element.first(:option, value).selected?
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
|
end
|
2022-10-10 09:41:33 +02:00
|
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
|
|
|
|
# show retry status in spec process
|
|
|
|
|
config.verbose_retry = true
|
|
|
|
|
# show exception that triggers a retry if verbose_retry is set to true
|
|
|
|
|
config.display_try_failure_messages = true
|
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
|
config.retry_count_condition = proc do |ex|
|
|
|
|
|
if ENV["CI"] == "true" && ex.metadata[:js]
|
|
|
|
|
3
|
|
|
|
|
else # in dev we want to have real error fast
|
|
|
|
|
1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-10-10 09:41:33 +02:00
|
|
|
|
# callback to be run between retries
|
|
|
|
|
config.retry_callback = proc do |ex|
|
|
|
|
|
# run some additional clean up task - can be filtered by example metadata
|
|
|
|
|
if ex.metadata[:js]
|
|
|
|
|
Capybara.reset!
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|