Skip to content

Commit

Permalink
Prevent breaking change for assertion message in test
Browse files Browse the repository at this point in the history
Follow up rubocop/rubocop#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
 "
```
  • Loading branch information
koic committed Mar 25, 2023
1 parent 4149cbd commit a96a985
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#247](https://github.com/rubocop/rubocop-minitest/pull/247): Prevent breaking change for assertion message in test. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/minitest/assert_offense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a96a985

Please sign in to comment.