-
-
Notifications
You must be signed in to change notification settings - Fork 572
Closed
Description
Summary:
Rails 5.1 introduced "System Tests", the brave new world of automated testing in Rails. It seems like this has been refined quite a bit and will become more prevalent in Rails 6.0. We'd like to get ahead of the curve on this.
Task:
We need to convert /spec/features/admin/dashboard_spec.rb from a feature spec to a system spec. There are 4 steps to this:
- Create a similarly named file in the
spec/systemdirectory. For example if the file was calledhappy_spec.rbit would be calledhappy_system_spec.rbin the new directory. - Set each spec’s type as type: :System
- Use RSpec.describe to define system specs, instead of RSpec.feature
- Replace the scenario alias in previous feature specs with the standard it syntax
Two files have already been converted that you can use as examples -- the account_system_spec.rb spec and the adjustment_system_spec.rb spec. You can also see the original feature files at account_spec.rb spec and adjustment_spec.rb spec.
More information on system specs can be found below.
Reference
- https://edgeguides.rubyonrails.org/testing.html#system-testing
- https://relishapp.com/rspec/rspec-rails/docs/system-specs/system-spec
- https://medium.com/table-xi/a-quick-guide-to-rails-system-tests-in-rspec-b6e9e8a8b5f6
- https://dev.to/aergonaut/running-rails-5-system-tests-on-travis-ci-with-chromedriver-4nm7
- http://blog.mechanicles.com/2018/03/04/gotchas-rails-system-testing.html
- https://everydayrails.com/2018/01/08/rspec-3.7-system-tests.html