RuboCop Minitest
A RuboCop extension focused on enforcing Minitest best practices and coding conventions. The library is based on the guidelines outlined in the community Minitest Style Guide.
Installation
Just install the rubocop-minitest gem
$ gem install rubocop-minitestor if you use bundler put this in your Gemfile
gem 'rubocop-minitest', require: falseUsage
You need to tell RuboCop to load the Minitest extension. There are three ways to do this:
RuboCop configuration file
Put this into your .rubocop.yml.
plugins: rubocop-minitestAlternatively, use the following array notation when specifying multiple extensions.
plugins:
- rubocop-other-extension
- rubocop-minitestNow you can run rubocop and it will automatically load the RuboCop Minitest
cops together with the standard cops.
Note
The plugin system is supported in RuboCop 1.72+. In earlier versions, use require instead of plugins.
Command line
$ rubocop --plugin rubocop-minitestRake task
require 'rubocop/rake_task'
RuboCop::RakeTask.new do |task|
task.plugins << 'rubocop-minitest'
endThe Cops
All cops are located under
lib/rubocop/cop/minitest, and contain
examples/documentation. The documentation is published here.
In your .rubocop.yml, you may treat the Minitest cops just like any other
cop. For example:
Minitest/AssertNil:
Exclude:
- test/my_file_to_ignore_test.rbDocumentation
You can read a lot more about RuboCop Minitest in its official docs.
Readme Badge
If you use RuboCop Minitest in your project, you can include one of these badges in your readme to let people know that your code is written following the community Minitest Style Guide.
Here are the Markdown snippets for the two badges:
[](https://github.com/rubocop/rubocop-minitest)
[](https://minitest.rubystyle.guide)Contributing
Checkout the contribution guidelines.
License
rubocop-minitest is MIT licensed. See the accompanying file for
the full text.