From 2fed7b9db358913d4403858e8aa8f733014aa1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 21:17:51 +0200 Subject: [PATCH] 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. --- .rubocop_basic.yml | 3 +++ spec/features/admin/emails/emails_download_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index e6578c2d3..d675de4e0 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -117,6 +117,9 @@ Layout/TrailingBlankLines: Layout/TrailingWhitespace: Enabled: true +Lint/AmbiguousRegexpLiteral: + Enabled: true + Lint/LiteralAsCondition: Enabled: true diff --git a/spec/features/admin/emails/emails_download_spec.rb b/spec/features/admin/emails/emails_download_spec.rb index 9a2e0a445..fce00f9a0 100644 --- a/spec/features/admin/emails/emails_download_spec.rb +++ b/spec/features/admin/emails/emails_download_spec.rb @@ -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"]