Skip to content

Commit

Permalink
Add test for rubocop#8805
Browse files Browse the repository at this point in the history
  • Loading branch information
owst committed Sep 28, 2020
1 parent 201fc15 commit 770b91e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/rubocop/cop/style/redundant_regexp_escape_spec.rb
Expand Up @@ -442,6 +442,19 @@
end
end

context 'with a # inside a character class' do
it 'does not register an offense' do
# See https://github.com/rubocop-hq/rubocop/issues/8805 - the # inside the character class
# must not be treated as starting a comment (which makes the following \. redundant)
expect_no_offenses(<<~'RUBY')
regexp = %r{
\A[a-z#] # letters or #
\.[a-z]\z # dot + letters
}x
RUBY
end
end

context 'with redundantly-escaped slashes' do
it 'registers an offense and corrects' do
expect_offense(<<~'RUBY')
Expand Down

0 comments on commit 770b91e

Please sign in to comment.