Minitest
Minitest/AssertEmpty
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.2 |
- |
This cop enforces the test to use assert_empty
instead of using assert(object.empty?)
.
Minitest/AssertEqual
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.4 |
- |
This cop enforces the use of assert_equal(expected, actual)
over assert(expected == actual)
.
Minitest/AssertInDelta
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces the test to use assert_in_delta
instead of using assert_equal
to compare floats.
Minitest/AssertIncludes
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.2 |
- |
This cop enforces the test to use assert_includes
instead of using assert(collection.include?(object))
.
Minitest/AssertInstanceOf
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.4 |
- |
This cop enforces the test to use assert_instance_of(Class, object)
over assert(object.instance_of?(Class))
.
Minitest/AssertKindOf
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces the test to use assert_kind_of(Class, object)
over assert(object.kind_of?(Class))
.
Minitest/AssertMatch
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.6 |
- |
This cop enforces the test to use assert_match
instead of using assert(matcher.match(string))
.
Minitest/AssertNil
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.1 |
- |
This cop enforces the test to use assert_nil
instead of using assert_equal(nil, something)
.
Examples
# bad
assert_equal(nil, actual)
assert_equal(nil, actual, 'message')
# good
assert_nil(actual)
assert_nil(actual, 'message')
Minitest/AssertOutput
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
No |
0.10 |
- |
This cop checks for opportunities to use assert_output
.
Minitest/AssertPathExists
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces the test to use assert_path_exists
instead of using assert(File.exist?(path))
.
Minitest/AssertRespondTo
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.3 |
- |
This cop enforces the use of assert_respond_to(object, :do_something)
over assert(object.respond_to?(:do_something))
.
Minitest/AssertSilent
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces the test to use assert_silent { … }
instead of using assert_output('', '') { … }
.
Minitest/AssertTruthy
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.2 |
- |
This cop enforces the test to use assert(actual)
instead of using assert_equal(true, actual)
.
Minitest/AssertWithExpectedArgument
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
No |
No |
0.11 |
- |
This cop tries to detect when a user accidentally used
assert
when they meant to use assert_equal
.
It is marked as unsafe because it is not possible to determine
whether the second argument of assert
is a message or not.
Minitest/AssertionInLifecycleHook
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
No |
0.10 |
- |
This cop checks for usage of assertions in lifecycle hooks.
Minitest/GlobalExpectations
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.7 |
- |
This cop checks for deprecated global expectations and autocorrects them to use expect format.
Minitest/LiteralAsActualArgument
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces correct order of expected and
actual arguments for assert_equal
.
Minitest/MultipleAssertions
Minitest/NoAssertions
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Disabled |
Yes |
No |
0.12 |
- |
This cop checks if test cases contain any assertion calls.
Minitest/RefuteEmpty
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.3 |
- |
This cop enforces to use refute_empty
instead of
using refute(object.empty?)
.
Minitest/RefuteEqual
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.3 |
- |
This cop enforces the use of refute_equal(expected, object)
over assert(expected != actual)
or assert(! expected == actual)
.
Minitest/RefuteFalse
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.3 |
- |
This cop enforces the use of refute(object)
over assert_equal(false, object)
.
Minitest/RefuteInDelta
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces the test to use refute_in_delta
instead of using refute_equal
to compare floats.
Minitest/RefuteIncludes
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.3 |
- |
This cop enforces the test to use refute_includes
instead of using refute(collection.include?(object))
.
Minitest/RefuteInstanceOf
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.4 |
- |
This cop enforces the use of refute_instance_of(Class, object)
over refute(object.instance_of?(Class))
.
Minitest/RefuteKindOf
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces the use of refute_kind_of(Class, object)
over refute(object.kind_of?(Class))
.
Minitest/RefuteMatch
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.6 |
- |
This cop enforces the test to use refute_match
instead of using refute(matcher.match(string))
.
Minitest/RefuteNil
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.2 |
- |
This cop enforces the test to use refute_nil
instead of using refute_equal(nil, something)
.
Examples
# bad
refute_equal(nil, actual)
refute_equal(nil, actual, 'message')
# good
refute_nil(actual)
refute_nil(actual, 'message')
Minitest/RefutePathExists
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces the test to use refute_path_exists
instead of using refute(File.exist?(path))
.
Minitest/RefuteRespondTo
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Enabled |
Yes |
Yes |
0.4 |
- |
This cop enforces the test to use refute_respond_to(object, :do_something)
over refute(object.respond_to?(:do_something))
.
Minitest/TestMethodName
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
Yes |
0.10 |
- |
This cop enforces that test method names start with test_
prefix.
It aims to prevent tests that aren’t executed by forgetting to start test method name with test_
.
Minitest/UnspecifiedException
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged |
---|---|---|---|---|
Pending |
Yes |
No |
0.10 |
- |
This cop checks for a specified error in assert_raises
.