-
Notifications
You must be signed in to change notification settings - Fork 20
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
Convert Frontend Test Runner from Minitest to RSpec #4090
Conversation
24deebd
to
37abcc8
Compare
0a7c385
to
7364a45
Compare
06c3f02
to
f408914
Compare
f408914
to
bd62135
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good. And the tests are running 🎉
A couple of things I'm not sure about is the nesting of the components helper modules. Other thoughts / comments are inline.
- Move the fixture file used by this test
- Update to use CalendarHelpers rather than test code in Calendar class.
- Remove content_schema_helpers, and reference in the CalendarPublisher spec. For the test we're making here, it's a lighter touch to remove the dependency on Mocha and just match the actual example rather than validating that it matches a schema.
- Move fixture file used by theses tests
- Update Calendar spec to use CalendarHelper rather than test code in Calendar class. - Move fixture used in this test
- Also suppress the "good job!" message which messes up the neat RSpec dots.
- delete unused fixture - delete _helper files from test - remove test-related gems - remove content_store_helpers from test/support, the only remaining functions in it were never used.
- Neither of these methods are referenced in the app.
e6cb59f
to
aaef2fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
END OF AN ERA!
Well done on not giving up in the face of 8 thousand review comments 💪
Those 8 thousand review comments helped it move from a poorly formed mass of clay into a fine china pot (with a few blemishes). Thanks @hannako and @leenagupte for all the suggestions! |
NB: Currently failing checks because it's expecting a minitest check - as long as that's the only failure it is safe to merge but we will need to update the settings
What
Replace Frontend's existing minitest test suite with the equivalent in RSpec.
Why
RSpec is our standard, and we want to merge some smaller apps (using RSpec test suites) into Frontend. We have decided it's better to rewrite the larger app to conform to our standard than move the smaller app in the other direction.
Trello card
How
We do the bulk of the conversion using a fork of the minitest_to_rspec gem; then tidy up the code with rubocop before manually tweaking the remaining tests that don't run. Finally we compare coverage to ensure that we have the same between the versions.
Coverage
Line coverage is slightly improved (97.8% -> 97.94%)
Style decisions I have made (and can unmake!)
In tidying up the autogenerated specs, I've made a bunch of style decisions that aren't really covered by rubocop but which I've tried to maintain to keep the new files consistent with other spec tests (we don't have a perfect consistency in other apps, but there's a rough consensus). I'm not married to these decisions, so feel free to comment on them and we can update the files:
#to
and#not_to
don't.#describe
for the top block in a file, and for any block that is a named method,#context
otherwise.Test Type Conversion
The current idiom is to prefer system spec over feature specs, so all feature tests have been converted to system specs, and request specs over controller specs, so all controller tests have been converted to request specs. Note that in a few cases this has meant a slight adjustment to the tests (some previous controller tests were not suitable for request specs, so have been moved into the system specs for the related feature, and some tests have been simplified as above).
In addition, I've moved tests into directories that reflect their test types, allowing us to avoid explicit test types with teh
config.infer_spec_type_from_file_location!
RSpec directive - so some of the previous unit tests are moved out into /models and /helpers. Ideally no test types should be added explicitly. The sole exception to this is components, since by convention we tend to put those in /components, and they need to be a mixture of view types (the actual component tests) and default type (the all_components code).Decisions I have avoided making
I haven't closely examined each test to determine whether it's actually worthwhile as a test. Some of the reviewers pointed out tests that are not great, I've dealt with them. But don't take this PR as an endorsement of the quality of individual tests.