From a96a985467481659c757bc26a0dcd0f550204644 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 25 Mar 2023 16:08:16 +0900 Subject: [PATCH] Prevent breaking change for assertion message in test Follow up https://github.com/rubocop/rubocop/pull/11729. This PR prevents breaking change for assertion message in test. e.g. ```console % bundle exec ruby -Itest test/rubocop/cop/minitest/lifecycle_hooks_order_test.rb (snip) Fabulous run in 0.075080s, 93.2339 runs/s, 93.2339 assertions/s. 1) Failure: LifecycleHooksOrderTest#test_registers_offense_when_hooks_are_not_before_test_cases [test/rubocop/cop/minitest/lifecycle_hooks_order_test.rb:62]: --- expected +++ actual @@ -4,7 +4,7 @@ end def setup; end - ^^^^^^^^^^^^^^ `setup` is supposed to appear before `test_something`. + ^^^^^^^^^^^^^^ Minitest/LifecycleHooksOrder: `setup` is supposed to appear before `test_something`. def teardown; end end " ``` --- ...fix_prevent_breaking_change_for_assertion_message_in_test.md | 1 + lib/rubocop/minitest/assert_offense.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/fix_prevent_breaking_change_for_assertion_message_in_test.md diff --git a/changelog/fix_prevent_breaking_change_for_assertion_message_in_test.md b/changelog/fix_prevent_breaking_change_for_assertion_message_in_test.md new file mode 100644 index 00000000..84e3e52e --- /dev/null +++ b/changelog/fix_prevent_breaking_change_for_assertion_message_in_test.md @@ -0,0 +1 @@ +* [#247](https://github.com/rubocop/rubocop-minitest/pull/247): Prevent breaking change for assertion message in test. ([@koic][]) diff --git a/lib/rubocop/minitest/assert_offense.rb b/lib/rubocop/minitest/assert_offense.rb index f62f13dc..fd17cfc3 100644 --- a/lib/rubocop/minitest/assert_offense.rb +++ b/lib/rubocop/minitest/assert_offense.rb @@ -79,7 +79,7 @@ def setup cop_name = self.class.to_s.delete_suffix('Test') return unless RuboCop::Cop::Minitest.const_defined?(cop_name) - @cop = RuboCop::Cop::Minitest.const_get(cop_name).new + @cop = RuboCop::Cop::Minitest.const_get(cop_name).new(configuration) end def format_offense(source, **replacements)