百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rubocop-minitest

> 数据库
开源

检查 Minitest 文件的代码风格。

165 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

检查 Minitest 文件的代码风格。

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

bash
$ gem install rubocop-minitest

or if you use bundler put this in your Gemfile

ruby
gem 'rubocop-minitest', require: false

Usage

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.

yaml
plugins: rubocop-minitest

Alternatively, use the following array notation when specifying multiple extensions.

yaml
plugins:
  - rubocop-other-extension
  - rubocop-minitest

Now 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

bash
$ rubocop --plugin rubocop-minitest

Rake task

ruby
require 'rubocop/rake_task'

RuboCop::RakeTask.new do |task|
  task.plugins  1 }
  end

  def target_ruby_version
    3.0
  end
end

To change them for a single test, assign them in the test method. This makes it possible for tests targeting different Ruby versions to live in the same test class:

ruby
class MyCopTest < RuboCop::TestCase
  def test_registers_offense_on_ruby31
    self.target_ruby_version = 3.1

    assert_offense(<<~RUBY)
      bad_method
      ^^^^^^^^^^ Use `good_method` instead of `bad_method`.
    RUBY
  end

  def test_does_not_register_offense_on_ruby30
    self.target_ruby_version = 3.0

    assert_no_offenses(<<~RUBY)
      bad_method
    RUBY
  end
end

The default configuration of extensions registered as lint_roller plugins is applied automatically. For other extensions, call RuboCop::ConfigLoader.inject_defaults!('path/to/default.yml') in your test helper.

Documentation

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:

markdown

Contributing

Checkout the contribution guidelines.

License

rubocop-minitest is MIT licensed. See the accompanying file for the full text.

Issues· 11 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubycode-formatterhacktoberfestlinterminitest

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库