rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Cop Idea: prevent "it works" description

Open BigBigDoudou opened this issue 2 years ago • 4 comments

I see too many this:

it "works" do
  # ...
end

Specs are not just here to prevent bugs, but are, as the name implies, specifications. In other words, a documentation we can use as developer to understand what the code is supposed to do.

So it could be nice to enforce a description of "what it does". Preventing "it works" would be a good start 😋

# bad

it "works" do
  # ...
end

# good

it "marks the task as done" do
  # ...
end

BigBigDoudou avatar Jul 27 '22 08:07 BigBigDoudou

Sounds great. Would you like to open a PR with such a cop? It should be an easy one. There's RSpec/ContextDescription for the reference.

pirj avatar Jul 27 '22 11:07 pirj

It can have a configuration for disallowed patterns

Darhazer avatar Jul 27 '22 12:07 Darhazer

Sounds great. Would you like to open a PR with such a cop? It should be an easy one. There's RSpec/ContextDescription for the reference.

That would be my first cop but there's no rush so yeah I can do it someday.

BigBigDoudou avatar Jul 27 '22 12:07 BigBigDoudou

took a stab at this cop requirement! happy to make any changes!

akrox58 avatar Aug 03 '22 07:08 akrox58