wordpress-mobile / wordpress-mobile/release-toolkit

What's a good value for RSpec example length?

Open
#248 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
31
Forks
10
Avg merge
5h 45m
Merged PRs (30d)
2

Description

When working on https://github.com/wordpress-mobile/release-toolkit/pull/242, I added some tests and RuboCop warned me they should have been 5 lines or less.

RSpec/ExampleLength: Example has too many lines [7/5].

I addressed the violation with a cheap trick.

I'm all in for having short methods actually, I do really like the Sandi Metz rules. But, in the context of that commit, I feel like I didn't make the test more readable.

I can see two options:

  • Relax the rule to acknowledge the current state of this codebase, where there's a lot of setup and mocking required for testing
  • Stick with the rule, and do our best to work within it in a way that makes the codebase better.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the RuboCop RSpec/ExampleLength warning and the linked pull request 242, including commit b63a2a30ee5de849c3146f29fd9692b0d28913c5. Decide whether the five-line limit fits this codebase's test setup and mocking patterns; done means reaching and documenting a clear decision about relaxing the rule or keeping it.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.