From fd6b35270df1e0876c9415826efe17eaac5b897f Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Thu, 13 Oct 2022 21:59:44 +0200 Subject: [PATCH 1/3] Enable Layout/LineContinuationSpacing ...and fix offenses. --- .rubocop.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 6923ff2..678c213 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -95,6 +95,11 @@ Style/FormatStringToken: Exclude: - spec/rubocop/**/*.rb +# Enable some of RuboCop's pending cops. + +Layout/LineContinuationSpacing: + Enabled: true + # Enable our own pending cops. RSpec/BeEq: From 145227f829fea3e8585c9713e7df41394392d717 Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Thu, 13 Oct 2022 22:08:36 +0200 Subject: [PATCH 2/3] Enable Layout/LineEndStringConcatenationIndentation ...and fix offenses. --- .rubocop.yml | 2 ++ .../cop/capybara/specific_finders_spec.rb | 14 ++++++------ .../cop/capybara/specific_matcher_spec.rb | 22 +++++++++---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 678c213..b43bdb7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -99,6 +99,8 @@ Style/FormatStringToken: Layout/LineContinuationSpacing: Enabled: true +Layout/LineEndStringConcatenationIndentation: + Enabled: true # Enable our own pending cops. diff --git a/spec/rubocop/cop/capybara/specific_finders_spec.rb b/spec/rubocop/cop/capybara/specific_finders_spec.rb index 5996f06..fc2bda6 100644 --- a/spec/rubocop/cop/capybara/specific_finders_spec.rb +++ b/spec/rubocop/cop/capybara/specific_finders_spec.rb @@ -35,7 +35,7 @@ end it 'registers an offense when using `find` and other args ' \ - 'with no parentheses' do + 'with no parentheses' do expect_offense(<<~RUBY) find '#some-id', exact_text: 'foo' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `find_by` over `find`. @@ -60,7 +60,7 @@ end it 'registers an offense when using `find ' \ - 'with argument is attribute specified id' do + 'with argument is attribute specified id' do expect_offense(<<~RUBY) find('[id=some-id]') ^^^^^^^^^^^^^^^^^^^^ Prefer `find_by` over `find`. @@ -78,7 +78,7 @@ end it 'does not register an offense when using `find ' \ - 'with argument is attribute not specified id' do + 'with argument is attribute not specified id' do expect_no_offenses(<<~RUBY) find('[visible]') find('[class=some-cls][visible]') @@ -86,21 +86,21 @@ end it 'does not register an offense when using `find ' \ - 'with argument is element with id' do + 'with argument is element with id' do expect_no_offenses(<<~RUBY) find('h1#some-id') RUBY end it 'does not register an offense when using `find ' \ - 'with argument is element with attribute specified id' do + 'with argument is element with attribute specified id' do expect_no_offenses(<<~RUBY) find('h1[id=some-id]') RUBY end it 'does not register an offense when using `find` ' \ - 'with argument is not id' do + 'with argument is not id' do expect_no_offenses(<<~RUBY) find('a.some-id') find('.some-id') @@ -114,7 +114,7 @@ end it 'does not register an offense when using `find` ' \ - 'with argument is id with multiple matcher' do + 'with argument is id with multiple matcher' do expect_no_offenses(<<~RUBY) find('#some-id body') find('#some-id>h1') diff --git a/spec/rubocop/cop/capybara/specific_matcher_spec.rb b/spec/rubocop/cop/capybara/specific_matcher_spec.rb index 868bb78..0a605cd 100644 --- a/spec/rubocop/cop/capybara/specific_matcher_spec.rb +++ b/spec/rubocop/cop/capybara/specific_matcher_spec.rb @@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::RSpec::Capybara::SpecificMatcher do it 'does not register an offense for abstract matcher when ' \ - 'first argument is not a replaceable element' do + 'first argument is not a replaceable element' do expect_no_offenses(<<-RUBY) expect(page).to have_selector('article') expect(page).to have_no_selector('body') @@ -11,7 +11,7 @@ end it 'does not register an offense for abstract matcher when ' \ - 'first argument is not an element' do + 'first argument is not an element' do expect_no_offenses(<<-RUBY) expect(page).to have_no_css('.a') expect(page).to have_selector('#button') @@ -206,7 +206,7 @@ class style visible obscured exact exact_text normalize_ws match wait end it 'registers an offense when using abstract matcher with ' \ - 'first argument is element with replaceable pseudo-classes' do + 'first argument is element with replaceable pseudo-classes' do expect_offense(<<-RUBY) expect(page).to have_css('button:not([disabled])', exact_text: 'bar') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `have_button` over `have_css`. @@ -216,7 +216,7 @@ class style visible obscured exact exact_text normalize_ws match wait end it 'registers an offense when using abstract matcher with ' \ - 'first argument is element with multiple replaceable pseudo-classes' do + 'first argument is element with multiple replaceable pseudo-classes' do expect_offense(<<-RUBY) expect(page).to have_css('button:not([disabled]):enabled') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `have_button` over `have_css`. @@ -234,22 +234,22 @@ class style visible obscured exact exact_text normalize_ws match wait end it 'does not register an offense when using abstract matcher with ' \ - 'first argument is element with replaceable pseudo-classes' \ - 'and not boolean attributes' do + 'first argument is element with replaceable pseudo-classes' \ + 'and not boolean attributes' do expect_no_offenses(<<-RUBY) expect(page).to have_css('button:not([name="foo"][disabled])') RUBY end it 'does not register an offense when using abstract matcher with ' \ - 'first argument is element with multiple nonreplaceable pseudo-classes' do + 'first argument is element with multiple nonreplaceable pseudo-classes' do expect_no_offenses(<<-RUBY) expect(page).to have_css('button:first-of-type:not([disabled])') RUBY end it 'does not register an offense for abstract matcher when ' \ - 'first argument is element with nonreplaceable attributes' do + 'first argument is element with nonreplaceable attributes' do expect_no_offenses(<<-RUBY) expect(page).to have_css('button[data-disabled]') expect(page).to have_css('button[foo=bar]') @@ -258,7 +258,7 @@ class style visible obscured exact exact_text normalize_ws match wait end it 'does not register an offense for abstract matcher when ' \ - 'first argument is element with multiple nonreplaceable attributes' do + 'first argument is element with multiple nonreplaceable attributes' do expect_no_offenses(<<-RUBY) expect(page).to have_css('button[disabled][foo]') expect(page).to have_css('button[foo][disabled]') @@ -269,7 +269,7 @@ class style visible obscured exact exact_text normalize_ws match wait end it 'does not register an offense for abstract matcher when ' \ - 'first argument is element with sub matcher' do + 'first argument is element with sub matcher' do expect_no_offenses(<<-RUBY) expect(page).to have_css('button body') expect(page).to have_css('a,h1') @@ -279,7 +279,7 @@ class style visible obscured exact exact_text normalize_ws match wait end it 'does not register an offense for abstract matcher when ' \ - 'first argument is dstr' do + 'first argument is dstr' do expect_no_offenses(<<-'RUBY') expect(page).to have_css(%{a[href="#{foo}"]}, text: "bar") RUBY From 55351cda0d58af18b3f54e74414fdf44eb472d0e Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Thu, 13 Oct 2022 22:25:56 +0200 Subject: [PATCH 3/3] Enable Style/EmptyHeredoc and fix offense --- .rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index b43bdb7..8a0d888 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -101,6 +101,8 @@ Layout/LineContinuationSpacing: Enabled: true Layout/LineEndStringConcatenationIndentation: Enabled: true +Style/EmptyHeredoc: + Enabled: true # Enable our own pending cops.