Skip to content

Commit

Permalink
Cut 0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Sep 8, 2022
1 parent 8b794e3 commit 488a313
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 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.22.0 (2022-09-08)

### New features

* [#179](https://github.com/rubocop/rubocop-minitest/pull/179): New `Minitest/AssertRaisesWithRegexpArgument` cop checks for regular expression literals passed to `assert_raises`. ([@rwstauner][])
Expand Down
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Minitest/AssertRaisesCompoundBody:
Minitest/AssertRaisesWithRegexpArgument:
Description: 'This cop enforces checks for regular expression literals passed to `assert_raises`.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '0.22'

Minitest/AssertRespondTo:
Description: 'This cop enforces the test to use `assert_respond_to(object, :do_something)` over `assert(object.respond_to?(:do_something))`.'
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.22'
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 @@ -26,6 +26,7 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide].
* xref:cops_minitest.adoc#minitestassertpathexists[Minitest/AssertPathExists]
* xref:cops_minitest.adoc#minitestassertpredicate[Minitest/AssertPredicate]
* xref:cops_minitest.adoc#minitestassertraisescompoundbody[Minitest/AssertRaisesCompoundBody]
* xref:cops_minitest.adoc#minitestassertraiseswithregexpargument[Minitest/AssertRaisesWithRegexpArgument]
* xref:cops_minitest.adoc#minitestassertrespondto[Minitest/AssertRespondTo]
* xref:cops_minitest.adoc#minitestassertsilent[Minitest/AssertSilent]
* xref:cops_minitest.adoc#minitestasserttruthy[Minitest/AssertTruthy]
Expand Down
35 changes: 35 additions & 0 deletions docs/modules/ROOT/pages/cops_minitest.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,41 @@ assert_raises(MyError) do
end
----

== Minitest/AssertRaisesWithRegexpArgument

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

| Pending
| Yes
| No
| 0.22
| -
|===

Checks for `assert_raises` with arguments of regular expression literals.
Arguments should be exception classes.
Optionally the last argument can be a custom message string to help explain failures.
Either way, it's not the argument that `exception.message` is compared to.
The raised exception is returned and can be used
to match against a regular expression.

=== Examples

[source,ruby]
----
# bad
assert_raises FooError, /some message/ do
obj.occur_error
end
# good
exception = assert_raises FooError do
obj.occur_error
end
assert_match(/some message/, exception.message)
----

== Minitest/AssertRespondTo

|===
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.21.1'
STRING = '0.22.0'

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

* [#179](https://github.com/rubocop/rubocop-minitest/pull/179): New `Minitest/AssertRaisesWithRegexpArgument` cop checks for regular expression literals passed to `assert_raises`. ([@rwstauner][])

### Bug fixes

* [#181](https://github.com/rubocop/rubocop-minitest/pull/181): Fix an incorrect autocorrect for `Minitest/AssertMatch` when `assert` with `match` and RHS is a regexp literal. ([@koic][])

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

0 comments on commit 488a313

Please sign in to comment.