8000 docs(ruby): add multiple expectations guide by kfitzpatrick · Pull Request #168 · habit-hooks/habit-hooks · GitHub
[go: up one dir, main page]

Skip to content
8000

docs(ruby): add multiple expectations guide - #168

Open
kfitzpatrick wants to merge 2 commits into
habit-hooks:mainfrom
kfitzpatrick:codex-rubocop-multiple-expectations-guide
Open

kfitzpatrick wants to merge 2 commits into
habit-hooks:mainfrom
kfitzpatrick:codex-rubocop-multiple-expectations-guide

Conversation

@kfitzpatrick
Copy link
Copy Markdown

Just a simple guide based off the official rspec-rubocop docs.

@kfitzpatrick
kfitzpatrick marked this pull request as ready for review September 14, 2026 02:37
@kfitzpatrick
kfitzpatrick marked this pull request as draft September 14, 2026 02:42
Comment thread docs/smell-vocabulary.md
| `deep-nesting` | Deep nesting | enforced |
| `oversized-file` | Oversized file | enforced |
| `oversized-block` | Oversized block | enforced |
| `multiple-expectations` | Multiple expectations | enforced |
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/smell-vocabulary.md
| `deep-nesting` | Deep nesting | enforced |
| `oversized-file` | Oversized file | enforced |
| `oversized-block` | Oversized block | enforced |
| `multiple-expectations` | Multiple expectations | enforced |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. 

@devill
devill commented Sep 24, 2026
Copy link
Copy Markdown
Collaborator

The PR is still in draft. Was it intended for review?

@kfitzpatrick
kfitzpatrick marked this pull request as ready for review October 16, 2026 01:40
@kfitzpatrick
Copy link
Copy Markdown
Author

@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!

@devill
devill commented Oct 16, 2026
Copy link
Copy Markdown
Collaborator

Things moved on, so please make sure to rebase your branch :)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0