rubocop / minitest-style-guide

Best practices for writing your tests
https://minitest.rubystyle.guide
70 stars 15 forks source link

Specifying files should end in `_test` or start with `test_` #34

Closed NatMorcos closed 4 years ago

NatMorcos commented 4 years ago

We were looking for a rubocop that enforced filenaming for minitest files, something similar to this one available when using RSpec: https://www.rubydoc.info/gems/rubocop-rspec/1.0/RuboCop/Cop/RSpec/FileName

There is no cop like this in the out-of-the-box minitest cop repo: https://github.com/rubocop-hq/rubocop-minitest

The minitest cop repo specifies that the listed cops are based on the recommendations in this style guide. While it would be easy for us to write a custom cop in our project to enforce the desired naming, I wonder if a more general change might be wanted? Before submitting a PR: How do contributors feel about adding a file naming recommendation to the style guide and in turn creating a file name enforcement cop?

andyw8 commented 4 years ago

Worth nothing that using _test at the end isn't universal, e.g. minitest itself uses test_ at the beginning: https://github.com/seattlerb/minitest/tree/master/test/minitest

But even if there's no strong convention, it would be still be useful to have a configurable cop to enforce one or the other.

NatMorcos commented 4 years ago

ah good point @andyw8! I didn't even think to check 😅. A configurable cop would be cool. I've updated the issue title.

andyw8 commented 4 years ago

~I noticed the minitest README also recommends "Define your tests as methods beginning with test_."~

Ignore, that's about tests, not test files.