diff options
Diffstat (limited to 'ci/custom_cops/test/support/cop_helper.rb')
-rw-r--r-- | ci/custom_cops/test/support/cop_helper.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ci/custom_cops/test/support/cop_helper.rb b/ci/custom_cops/test/support/cop_helper.rb index d259154df5..c2c6b969dd 100644 --- a/ci/custom_cops/test/support/cop_helper.rb +++ b/ci/custom_cops/test/support/cop_helper.rb @@ -16,6 +16,18 @@ module CopHelper rewrite(cop, processed_source) end + def assert_offense(cop, expected_message) + assert_not_empty( + cop.offenses, + "Expected offense with message \"#{expected_message}\", but got no offense" + ) + + offense = cop.offenses.first + carets = "^" * offense.column_length + + assert_equal expected_message, "#{carets} #{offense.message}" + end + private TARGET_RUBY_VERSION = 2.4 |