Repository navigation
docs(ruby): add multiple expectations guide - #168
kfitzpatrick wants to merge 2 commits into
Conversation
| | `deep-nesting` | Deep nesting | enforced | | ||
| | `oversized-file` | Oversized file | enforced | | ||
| | `oversized-block` | Oversized block | enforced | | ||
| | `multiple-expectations` | Multiple expectations | enforced | |
There was a problem hiding this comment.
One thing I'm not sure about is this line here. I suspect this is not a warning that will be in most tools and is ruby specific. It's not bad practice, but it's BDD specific.
There was a problem hiding this comment.
I like the smell, I'm not sure about the name for now. However I would definitely move this one to be suggested instead of enforced. It's too subjective.
| | `deep-nesting` | Deep nesting | enforced | | ||
| | `oversized-file` | Oversized file | enforced | | ||
| | `oversized-block` | Oversized block | enforced | | ||
| | `multiple-expectations` | Multiple expectations | enforced | |
There was a problem hiding this comment.
I like the smell, I'm not sure about the name for now. However I would definitely move this one to be suggested instead of enforced. It's too subjective.
| @@ -0,0 +1,46 @@ | |||
| Keep each example focused on one behavior and one clear reason to fail. | |||
There was a problem hiding this comment.
When creating guides, where possible we should aim for generic wording that works for any language, and move the guide to generic. Example code is discouraged in prompts for the same reason.
Here is an alternative draft for this prompt:
The tests marked bellow have multiple assert/expectation statements in them. This can indicate that the test is testing multiple things, and may break for multiple reasons. When that happens it makes identifying the cause of the test failure harder.
Please follow these steps when evaluating these steps:
- Judge if the expectations are testing one concept using multiple statements, or they should rather be in two separate tests.
- If the expectations are testing one concept, refactor by naming that concept, and creating a custom assertion/expectation or a helper method to wrap the statements in a single statement
- If the expectations are testing multiple concepts split the test into multiple smaller tests. Extract helper methods to avoid duplication.
|
The PR is still in draft. Was it intended for review? |
|
@devill thank you for the review. Yep, I meant to follow up on this, but day job got busy. I'll take a look at your comments. Thanks for your patience! |
|
Things moved on, so please make sure to rebase your branch :) |
Just a simple guide based off the official rspec-rubocop docs.