diff --git a/.rubocop.yml b/.rubocop.yml index b7274798..b47d0658 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,6 +21,12 @@ Style/SlicingWithRange: Enabled: true Lint/DeprecatedOpenSSLConstant: Enabled: true +Lint/MixedRegexpCaptureTypes: + Enabled: true +Style/RedundantRegexpCharacterClass: + Enabled: true +Style/RedundantRegexpEscape: + Enabled: true Layout/LineLength: Description: 'Limit lines to 80 characters.' diff --git a/features/step_definitions/capybara_steps.rb b/features/step_definitions/capybara_steps.rb index 71fb674f..0ab547f7 100644 --- a/features/step_definitions/capybara_steps.rb +++ b/features/step_definitions/capybara_steps.rb @@ -19,5 +19,5 @@ rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e end Then(/^the failing exception should be nice$/) do - expect(@error_message).to match(/expected to find css \"h1#doesnotexist\"/) + expect(@error_message).to match(/expected to find css "h1#doesnotexist"/) end diff --git a/lib/capybara/spec/session/node_spec.rb b/lib/capybara/spec/session/node_spec.rb index d6d48b19..bbcfa9bb 100644 --- a/lib/capybara/spec/session/node_spec.rb +++ b/lib/capybara/spec/session/node_spec.rb @@ -758,7 +758,7 @@ Capybara::SpecHelper.spec 'node' do @session.visit('with_js') @session.find(:css, '#click-test').click(x: 5, y: 5) link = @session.find(:link, 'has-been-clicked') - locations = link.text.match(/^Has been clicked at (?[\d\.-]+),(?[\d\.-]+)$/) + locations = link.text.match(/^Has been clicked at (?[\d.-]+),(?[\d.-]+)$/) # Resulting click location should be very close to 0, 0 relative to top left corner of the element, but may not be exact due to # integer/float conversions and rounding. expect(locations[:x].to_f).to be_within(1).of(5) @@ -884,7 +884,7 @@ Capybara::SpecHelper.spec 'node' do @session.visit('with_js') @session.find(:css, '#click-test').double_click(x: 10, y: 5) link = @session.find(:link, 'has-been-double-clicked') - locations = link.text.match(/^Has been double clicked at (?[\d\.-]+),(?[\d\.-]+)$/) + locations = link.text.match(/^Has been double clicked at (?[\d.-]+),(?[\d.-]+)$/) # Resulting click location should be very close to 10, 5 relative to top left corner of the element, but may not be exact due # to integer/float conversions and rounding. expect(locations[:x].to_f).to be_within(1).of(10) @@ -970,7 +970,7 @@ Capybara::SpecHelper.spec 'node' do @session.visit('with_js') @session.find(:css, '#click-test').right_click(x: 10, y: 10) link = @session.find(:link, 'has-been-right-clicked') - locations = link.text.match(/^Has been right clicked at (?[\d\.-]+),(?[\d\.-]+)$/) + locations = link.text.match(/^Has been right clicked at (?[\d.-]+),(?[\d.-]+)$/) # Resulting click location should be very close to 10, 10 relative to top left corner of the element, but may not be exact due # to integer/float conversions and rounding expect(locations[:x].to_f).to be_within(1).of(10) diff --git a/spec/rspec/shared_spec_matchers.rb b/spec/rspec/shared_spec_matchers.rb index 064e467c..b7825402 100644 --- a/spec/rspec/shared_spec_matchers.rb +++ b/spec/rspec/shared_spec_matchers.rb @@ -606,7 +606,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode| visit('/with_js') expect do expect(session).to have_current_path('/not_with_js') - end.to raise_error(%r{to equal "/not\_with\_js"}) + end.to raise_error(%r{to equal "/not_with_js"}) end context 'with wait' do