diff --git a/CHANGELOG.md b/CHANGELOG.md index d901d834..cfcaab58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ## master (unreleased) +## 0.28.0 (2023-02-20) + ### New features * [#214](https://github.com/rubocop/rubocop-minitest/issues/214): Add new `Minitest/LifecycleHooksOrder` cop. ([@fatkodima][]) diff --git a/config/default.yml b/config/default.yml index 666754ae..45c88694 100644 --- a/config/default.yml +++ b/config/default.yml @@ -162,7 +162,7 @@ Minitest/LifecycleHooksOrder: Description: 'Checks that lifecycle hooks are declared in the order in which they will be executed.' StyleGuide: 'https://minitest.rubystyle.guide/#hooks-ordering' Enabled: pending - VersionAdded: '<>' + VersionAdded: '0.28' Minitest/LiteralAsActualArgument: Description: 'This cop enforces correct order of `expected` and `actual` arguments for `assert_equal`.' diff --git a/docs/antora.yml b/docs/antora.yml index 02c36842..b575cd71 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -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.28' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/pages/cops.adoc b/docs/modules/ROOT/pages/cops.adoc index bb9e6bfe..bffd4e70 100644 --- a/docs/modules/ROOT/pages/cops.adoc +++ b/docs/modules/ROOT/pages/cops.adoc @@ -36,6 +36,7 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide]. * xref:cops_minitest.adoc#minitestduplicatetestrun[Minitest/DuplicateTestRun] * xref:cops_minitest.adoc#minitestemptylinebeforeassertionmethods[Minitest/EmptyLineBeforeAssertionMethods] * xref:cops_minitest.adoc#minitestglobalexpectations[Minitest/GlobalExpectations] +* xref:cops_minitest.adoc#minitestlifecyclehooksorder[Minitest/LifecycleHooksOrder] * xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument] * xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions] * xref:cops_minitest.adoc#minitestnoassertions[Minitest/NoAssertions] diff --git a/docs/modules/ROOT/pages/cops_minitest.adoc b/docs/modules/ROOT/pages/cops_minitest.adoc index b56aed8e..7c116955 100644 --- a/docs/modules/ROOT/pages/cops_minitest.adoc +++ b/docs/modules/ROOT/pages/cops_minitest.adoc @@ -237,6 +237,8 @@ instead of using `assert(matcher.match(string))`. ---- # bad assert(matcher.match(string)) +assert(matcher.match?(string)) +assert(matcher =~ string) assert(matcher.match(string), 'message') # good @@ -903,6 +905,66 @@ value { musts }.must_raise TypeError * https://minitest.rubystyle.guide#global-expectations +== Minitest/LifecycleHooksOrder + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| Yes +| 0.28 +| - +|=== + +Checks that lifecycle hooks are declared in the order in which they will be executed. + +=== Examples + +[source,ruby] +---- +# bad +class FooTest < Minitest::Test + def teardown; end + def setup; end +end + +# good +class FooTest < Minitest::Test + def setup; end + def teardown; end +end + +# bad (after test cases) +class FooTest < Minitest::Test + def test_something + assert foo + end + def setup; end + def teardown; end +end + +# good +class FooTest < Minitest::Test + def setup; end + def teardown; end + def test_something + assert foo + end +end + +# good (after non test case methods) +class FooTest < Minitest::Test + def do_something; end + def setup; end + def teardown; end +end +---- + +=== References + +* https://minitest.rubystyle.guide/#hooks-ordering + == Minitest/LiteralAsActualArgument |=== @@ -1337,6 +1399,8 @@ instead of using `refute(matcher.match(string))`. ---- # bad refute(matcher.match(string)) +refute(matcher.match?(string)) +refute(matcher =~ string) refute(matcher.match(string), 'message') # good diff --git a/lib/rubocop/minitest/version.rb b/lib/rubocop/minitest/version.rb index a9806ae8..4a47c1dc 100644 --- a/lib/rubocop/minitest/version.rb +++ b/lib/rubocop/minitest/version.rb @@ -4,7 +4,7 @@ module RuboCop module Minitest # This module holds the RuboCop Minitest version information. module Version - STRING = '0.27.0' + STRING = '0.28.0' def self.document_version STRING.match('\d+\.\d+').to_s diff --git a/relnotes/v0.28.0.md b/relnotes/v0.28.0.md new file mode 100644 index 00000000..308b3b83 --- /dev/null +++ b/relnotes/v0.28.0.md @@ -0,0 +1,9 @@ +### New features + +* [#214](https://github.com/rubocop/rubocop-minitest/issues/214): Add new `Minitest/LifecycleHooksOrder` cop. ([@fatkodima][]) + +### Changes + +* [#239](https://github.com/rubocop/rubocop-minitest/issues/239): Enhance `AssertMatch`/`RefuteMatch` to check `match?` and `=~` methods. ([@fatkodima][]) + +[@fatkodima]: https://github.com/fatkodima