Add and apply AmbiguousRegexpLiteral rule

This is a very subtle behaviour: `match /attachment/i` could represent a
regular expression, but it could also represent a division like
`match / attachment / i`. So we need to make an exception to the usual
way we omit parenthesis in RSpec expectations.
This commit is contained in:
Javi Martín
2019-09-28 21:17:51 +02:00
parent d6eb9f8fb6
commit 2fed7b9db3
2 changed files with 5 additions and 2 deletions

View File

@@ -117,6 +117,9 @@ Layout/TrailingBlankLines:
Layout/TrailingWhitespace:
Enabled: true
Lint/AmbiguousRegexpLiteral:
Enabled: true
Lint/LiteralAsCondition:
Enabled: true

View File

@@ -33,8 +33,8 @@ describe "Admin download user emails" do
end
header = page.response_headers["Content-Disposition"]
expect(header).to match /^attachment/
expect(header).to match /filename="Administrators.csv"$/
expect(header).to match(/^attachment/)
expect(header).to match(/filename="Administrators.csv"$/)
file_contents = page.body.split(",")
expect(file_contents).to match_array ["admin_news1@consul.dev", "admin_news2@consul.dev"]