Skip to content

Commit

Permalink
Merge pull request #1410 from rubocop/bquorning.enable-some-new-cops
Browse files Browse the repository at this point in the history
Enable some new cops
  • Loading branch information
pirj authored Oct 13, 2022
2 parents 03a1f43 + 55351cd commit 9f28a25
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ Style/FormatStringToken:
Exclude:
- spec/rubocop/**/*.rb

# Enable some of RuboCop's pending cops.

Layout/LineContinuationSpacing:
Enabled: true
Layout/LineEndStringConcatenationIndentation:
Enabled: true
Style/EmptyHeredoc:
Enabled: true

# Enable our own pending cops.

RSpec/BeEq:
Expand Down
14 changes: 7 additions & 7 deletions spec/rubocop/cop/capybara/specific_finders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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`.
Expand All @@ -78,29 +78,29 @@
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]')
RUBY
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')
Expand All @@ -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')
Expand Down
22 changes: 11 additions & 11 deletions spec/rubocop/cop/capybara/specific_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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`.
Expand All @@ -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`.
Expand All @@ -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]')
Expand All @@ -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]')
Expand All @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 9f28a25

Please sign in to comment.