Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to use System Tests #1473

Closed
wants to merge 1 commit into from
Closed

Migrate to use System Tests #1473

wants to merge 1 commit into from

Conversation

seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Nov 22, 2019

Migrate from the rspec-rails-provided Feature Tests, to the
Rails-provided System Tests.

The most beneficial outcome of this migration is the ability to rely on
use_transactional_fixtures = true in
browser-driven (JavaScript-enabled).

In order to be System Test compatible, this commit replaces test block
declarations made with feature with RSpec.describe, along with calls
to scenario with it.

In order to continue to support rails@4.2 and rails@5.0, the test
harness must elect to run type: :feature tests when
[ActionDispatch::SystemTestCase][system-test-care] is not declared.

In those cases, to preserve compatibility:

  • pass type: :feature instead of type: :system to tests declared in
    spec/system
  • require database_cleaner gem, along with Feature-test compatible
    configuration

To achieve this, this commit introduces the SYSTEM_TEST constant,
which refers to the correct type: option: :feature for older
versions of Rails, :system for newer versions.

Once support for rails@4.2 and rails@5.0 is dropped, these
declarations can be removed, and type: SYSTEM_TEST options can be
search-and-replaced with type: :system.

Gemfile Show resolved Hide resolved
spec/support/chromedriver.rb Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
Migrate from the `rspec-rails`-provided Feature Tests, to the
Rails-provided [System Tests].

The most beneficial outcome of this migration is the ability to rely on
[`use_transactional_fixtures = true`][transactional-fixtures] in
browser-driven (JavaScript-enabled).

In order to be System Test compatible, this commit replaces test block
declarations made with `feature` with `RSpec.describe`, along with calls
to `scenario` with `it`.

In order to continue to support `rails@4.2` and `rails@5.0`, the test
harness must elect to run `type: :feature` tests when
[`ActionDispatch::SystemTestCase`][system-test-care] is not declared.

In those cases, to preserve compatibility:

* pass `type: :feature` instead of `type: :system` to tests declared in
  `spec/system`
* require `database_cleaner` gem, along with Feature-test compatible
  configuration

To achieve this, this commit introduces the `SYSTEM_TEST` constant,
which refers to the correct `type:` option: `:feature` for older
versions of Rails, `:system` for newer versions.

Once support for `rails@4.2` and `rails@5.0` is dropped, these
declarations can be removed, and `type: SYSTEM_TEST` options can be
search-and-replaced with `type: :system`.

[System Tests]: https://guides.rubyonrails.org/v5.1/testing.html#system-testing
[transactional-fixtures]:https://relishapp.com/rspec/rspec-rails/v/3-6/docs/transactions
[system-test-case]: https://api.rubyonrails.org/v5.1/classes/ActionDispatch/SystemTestCase.html
@nickcharlton
Copy link
Member

@seanpdoyle, is this something you'd like to continue with? I realise it's been a while and there's a few conflicts but I'm not adverse to switching to use the new system tests.

@seanpdoyle
Copy link
Contributor Author

@nickcharlton wow, I've forgotten about this. I don't have enough context on the codebase to estimate the effort involved in resolving these conflicts.

If you don't see a direct path toward resolution, we could close this.

That being said, I do think that adopting System Tests and Chromedriver would be valuable.

@nickcharlton
Copy link
Member

Hah, no worries!

I'm going to close this for now, as I'm not really sure either how much more work there would be. Since, we have switched to Chromedriver, so that's been a big improvement anyway. Thanks for opening this way back when!

@nickcharlton nickcharlton deleted the system-tests branch October 5, 2020 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance to keep up with changes around us
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants