This fixes the
> DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.
error appearing when running specs.
It also gets us closer from a newly-generated rails config.
rails_helper already has `ActiveRecord::Migration.maintain_test_schema!`
which automatically updates the test database if needed.
However, if we raise **before** `maintain_test_schema` had the chance
to do its job, the test database is never-automigrated.
Thus by removing the check, we ensure the test database will be migrated
as needed (and still an error will be raised if the schema cannot be
applied).
Test helpers are separated between two files: spec_helper and
rails_helper. This separation is meant to allow tests that do not
require Rails (like testing standalone libs) to boot faster.
The spec_helper file is always loaded, through `--require spec_helper`
in the `.rspec` config file. When needed, the rails_helper file is
expected to be required manually.
This is fine, but:
- Many test files have a redundant `require 'spec_helper'` line;
- Many test files should require `rails_helper`, but don't.
Not requiring `rails_helper` will cause the Rails-concerned section of
the test environment not to be configured–which may cause subtle bugs
(like the test database not being properly initialized).
Moreover, Spring loads all the Rails files on preloading anyway. So the
gains from using only `spec_helper` are thin.
To streamline this process, this commit:
- Configures `.rspec` to require `rails_helper` by default;
- Remove all manual requires to spec_helper or rails_helper.
Reference: https://stackoverflow.com/questions/24145329/how-is-spec-rails-helper-rb-different-from-spec-spec-helper-rb-do-i-need-it
Capybara's `have_select` can be very slow for elemtns with many options
(see https://github.com/teamcapybara/capybara/issues/1527)
This is because Capybara asserts that no other elements than the
required ones are selected.
This faster version is not as complete, but helps when checking the
countries list or the years in a date picker.
When requiring mina files, it automatically enables Rails traces. But
we don't want Rails traces during tests.
Fix this by disabling Rails traces before running tests.
Fix#2989
When a task is loaded several times, a single call of `task.invoke`
will run the task several times too.
This made `add_annotion_privee_to_procedure_spec` fail when it wasn't
the first task being tested.
Currently, when running specs, the output of rake tasks is spamming
the tests results.
This PR configures Rake so that it runs in quiet mode during specs. This
disables the internal messages of rake during tests.
However our own `puts` also need to be conditionned to the verbosity of
rake. Using a simple `rake_puts` helper allows the info messages to be
displayed when running the rake task manually, but not during tests.
Before:
```
$ bin/rspec spec/lib/rake
Randomized with seed 6544
1 Mails::ClosedMail to clean
cleaning Mails::ClosedMail #1
1 Mails::InitiatedMail to clean
cleaning Mails::InitiatedMail #1
1 Mails::ReceivedMail to clean
cleaning Mails::ReceivedMail #1
1 Mails::RefusedMail to clean
cleaning Mails::RefusedMail #1
1 Mails::WithoutContinuationMail to clean
cleaning Mails::WithoutContinuationMail #1
.....Champ 0/1
.Champ 0/1
.
```
After:
```
$ bin/rspec spec/lib/rake
Randomized with seed 6544
.......
```