Skip to content

Commit

Permalink
Cut 0.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Jan 30, 2023
1 parent 9600434 commit 3d0aeee
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master (unreleased)

## 0.27.0 (2023-01-30)

### New features

* [#220](https://github.com/rubocop/rubocop-minitest/issues/220): Add new `Minitest/NonPublicTestMethod` cop. ([@fatkodima][])
Expand Down
6 changes: 3 additions & 3 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Minitest/AssertTruthy:
Enabled: true
Safe: false
VersionAdded: '0.2'
VersionChanged: '<<next>>'
VersionChanged: '0.27'

Minitest/AssertWithExpectedArgument:
Description: 'This cop tries to detect when a user accidentally used `assert` when they meant to use `assert_equal`.'
Expand Down Expand Up @@ -179,7 +179,7 @@ Minitest/NonPublicTestMethod:
Description: 'Detects non `public` (marked as `private` or `protected`) test methods.'
Enabled: pending
Severity: warning
VersionAdded: '<<next>>'
VersionAdded: '0.27'

Minitest/RefuteEmpty:
Description: 'This cop enforces to use `refute_empty` instead of using `refute(object.empty?)`.'
Expand All @@ -199,7 +199,7 @@ Minitest/RefuteFalse:
Enabled: true
Safe: false
VersionAdded: '0.3'
VersionChanged: '<<next>>'
VersionChanged: '0.27'

Minitest/RefuteInDelta:
Description: 'This cop enforces the test to use `refute_in_delta` instead of using `refute_equal` to compare floats.'
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: rubocop-minitest
title: RuboCop Minitest
# We always provide version without patch here (e.g. 1.1),
# as patch versions should not appear in the docs.
version: ~
version: '0.27'
nav:
- modules/ROOT/nav.adoc
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
* xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument]
* xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions]
* xref:cops_minitest.adoc#minitestnoassertions[Minitest/NoAssertions]
* xref:cops_minitest.adoc#minitestnonpublictestmethod[Minitest/NonPublicTestMethod]
* xref:cops_minitest.adoc#minitestrefuteempty[Minitest/RefuteEmpty]
* xref:cops_minitest.adoc#minitestrefuteequal[Minitest/RefuteEqual]
* xref:cops_minitest.adoc#minitestrefutefalse[Minitest/RefuteFalse]
Expand Down
91 changes: 85 additions & 6 deletions docs/modules/ROOT/pages/cops_minitest.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,24 @@ assert_silent { puts object.do_something }
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Enabled
| Yes
| No
| Yes (Unsafe)
| 0.2
| 0.26
| 0.27
|===

Enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.

=== Safety

This cop's autocorrection is unsafe because true might be expected instead of truthy.
This cop is unsafe because true might be expected instead of truthy.
False positives cannot be prevented when this is a variable or method return value.

[source,ruby]
----
assert_equal(true, 'truthy') # failure
assert('truthy') # success
----

=== Examples

Expand Down Expand Up @@ -1013,6 +1020,67 @@ class FooTest < Minitest::Test
end
----

== Minitest/NonPublicTestMethod

|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Pending
| Yes
| No
| 0.27
| -
|===

Detects non `public` (marked as `private` or `protected`) test methods.
Minitest runs only test methods which are `public`.

=== Examples

[source,ruby]
----
# bad
class FooTest
private # or protected
def test_does_something
assert_equal 42, do_something
end
end
# good
class FooTest
def test_does_something
assert_equal 42, do_something
end
end
# good (not a test case name)
class FooTest
private # or protected
def does_something
assert_equal 42, do_something
end
end
# good (no assertions)
class FooTest
private # or protected
def test_does_something
do_something
end
end
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| Severity
| `warning`
| String
|===

== Minitest/RefuteEmpty

|===
Expand Down Expand Up @@ -1081,14 +1149,25 @@ refute_equal("rubocop-minitest", actual)
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Enabled
| Yes
| Yes
| No
| Yes (Unsafe)
| 0.3
| -
| 0.27
|===

Enforces the use of `refute(object)` over `assert_equal(false, object)`.

=== Safety

This cop is unsafe because it cannot detect failure when second argument is `nil`.
False positives cannot be prevented when this is a variable or method return value.

[source,ruby]
----
assert_equal(false, nil) # failure
refute(nil) # success
----

=== Examples

[source,ruby]
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/minitest/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RuboCop
module Minitest
# This module holds the RuboCop Minitest version information.
module Version
STRING = '0.26.1'
STRING = '0.27.0'

def self.document_version
STRING.match('\d+\.\d+').to_s
Expand Down
16 changes: 16 additions & 0 deletions relnotes/v0.27.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### New features

* [#220](https://github.com/rubocop/rubocop-minitest/issues/220): Add new `Minitest/NonPublicTestMethod` cop. ([@fatkodima][])

### Bug fixes

* [#237](https://github.com/rubocop/rubocop-minitest/pull/237): Fix a false positive for `Minitest/UselessAssertion` when using command execution. ([@fatkodima][])

### Changes

* [#234](https://github.com/rubocop/rubocop-minitest/pull/234): Mark `Minitest/AssertTruthy` as unsafe. ([@koic][])
* [#233](https://github.com/rubocop/rubocop-minitest/pull/233): Mark `Minitest/RefuteFalse` as unsafe. ([@koic][])
* [#231](https://github.com/rubocop/rubocop-minitest/pull/231): Change what is considered a test case by `rubocop-minitest` (`public` method without arguments with `test_` name prefix). ([@fatkodima][])

[@fatkodima]: https://github.com/fatkodima
[@koic]: https://github.com/koic

0 comments on commit 3d0aeee

Please sign in to comment.