This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes rubocop#12740. This PR tweaks annotation pattern for `expect_offense`. When there is no space between `^` annotation and message, as follows: ```ruby expect_offense(<<~RUBY) #!/usr/bin/env ruby # encoding: utf-8 ^^^^^^^^^^^^^^^^^Unnecessary utf-8 encoding comment. def foo() end RUBY ``` ## Before Despite being correct with `expect_offense`, it suggests using `expect_no_offenses`: ```console $ bundle exec rspec spec/rubocop/cop/style/encoding_spec.rb (snip) Failures: 1) RuboCop::Cop::Style::Encoding registers an offense when encoding present on 2nd line after shebang Failure/Error: raise 'Use `expect_no_offenses` to assert that no offenses are found' RuntimeError: Use `expect_no_offenses` to assert that no offenses are found # ./lib/rubocop/rspec/expect_offense.rb:196:in `parse_annotations' # ./lib/rubocop/rspec/expect_offense.rb:115:in `expect_offense' # ./spec/rubocop/cop/style/encoding_spec.rb:37:in `block (2 levels) in <top (required)>' ``` ## After It suggests that the usage of annotation is incorrect: ```console $ bundle exec rspec spec/rubocop/cop/style/encoding_spec.rb (snip) Failures: 1) RuboCop::Cop::Style::Encoding registers an offense when encoding present on 2nd line after shebang Failure/Error: expect(actual_annotations).to eq(expected_annotations), '' Diff: @@ -1,5 +1,5 @@ #!/usr/bin/env ruby # encoding: utf-8 -^^^^^^^^^^^^^^^^^Unnecessary utf-8 encoding comment. +^^^^^^^^^^^^^^^^^ Unnecessary utf-8 encoding comment. def foo() end # ./lib/rubocop/rspec/expect_offense.rb:123:in `expect_offense' # ./spec/rubocop/cop/style/encoding_spec.rb:37:in `block (2 levels) in <top (required)>' ```
- Loading branch information