Skip to content

Commit

Permalink
Rubocop rules updates
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Dec 11, 2023
1 parent e2f9f6c commit 2052ea8
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 9 deletions.
15 changes: 15 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ AllCops:
Capybara/NegationMatcher:
Enabled: false

RSpec/SpecFilePathFormat:
Enabled: false

RSpec/SpecFilePathSuffix:
Enabled: false

Capybara/RSpec/HaveSelector:
Enabled: false

Capybara/SpecificFinders:
Enabled: false

#################### Gemspec ###################

Gemspec/DevelopmentDependencies:
Expand Down Expand Up @@ -173,6 +185,9 @@ Style/AccessorGrouping:
Style/Alias:
Enabled: false

Style/ArgumentsForwarding:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def failure_message
message << ' but there were no matches'
else
message << ", found #{count} #{Capybara::Helpers.declension('match', 'matches', count)}: " \
<< full_results.map(&:text).map(&:inspect).join(', ')
<< full_results.map { |r| r.text.inspect }.join(', ')
end
unless rest.empty?
elements = rest.map { |el| el.text rescue '<<ERROR>>' }.map(&:inspect).join(', ') # rubocop:disable Style/RescueModifier
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selenium/nodes/chrome_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def perform_legacy_drag(element, drop_modifiers)

def browser_version(to_float: true)
caps = capabilities
ver = (caps[:browser_version] || caps[:version])
ver = caps[:browser_version] || caps[:version]
ver = ver.to_f if to_float
ver
end
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def responsive?

res = @checker.request { |http| http.get('/__identify__') }

return res.body == app.object_id.to_s if res.is_a?(Net::HTTPSuccess) || res.is_a?(Net::HTTPRedirection)
res.body == app.object_id.to_s if res.is_a?(Net::HTTPSuccess) || res.is_a?(Net::HTTPRedirection)
rescue SystemCallError, Net::ReadTimeout, OpenSSL::SSL::SSLError
false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/spec/session/all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
end

context 'with per session config', requires: [:psc] do
it 'should use the sessions ignore_hidden_elements', psc: true do
it 'should use the sessions ignore_hidden_elements', :psc do
Capybara.ignore_hidden_elements = true
@session.config.ignore_hidden_elements = false
expect(Capybara.ignore_hidden_elements).to be(true)
Expand Down
3 changes: 3 additions & 0 deletions lib/capybara/spec/session/click_link_or_button_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

# rubocop:disable Capybara/ClickLinkOrButtonStyle

Capybara::SpecHelper.spec '#click_link_or_button' do
it 'should click on a link' do
@session.visit('/with_html')
Expand Down Expand Up @@ -136,3 +138,4 @@
end
end
end
# rubocop:enable Capybara/ClickLinkOrButtonStyle
2 changes: 1 addition & 1 deletion lib/capybara/spec/session/click_link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

it "should raise an error if no link's href matched the pattern" do
expect { @session.click_link('labore', href: /invalid_pattern/) }.to raise_error(Capybara::ElementNotFound, %r{with href matching /invalid_pattern/})
expect { @session.click_link('labore', href: /.+d+/) }.to raise_error(Capybara::ElementNotFound, /#{Regexp.quote "with href matching /.+d+/"}/)
expect { @session.click_link('labore', href: /.+d+/) }.to raise_error(Capybara::ElementNotFound, /#{Regexp.quote 'with href matching /.+d+/'}/)
end

context 'href: nil' do
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def run_specs(session, name, **options, &filter_block)
session.reset_session!
end

before :each, psc: true do
before :each, :psc do
SpecHelper.reset_threadsafe(bool: true, session: session)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
end
end

it 'switches to the javascript driver when giving it as metadata', js: true do
it 'switches to the javascript driver when giving it as metadata', :js do
expect(Capybara.current_driver).to eq(Capybara.javascript_driver)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
app_proc = proc { |_env| [200, {}, ['Hello Puma!']] }
require 'puma'

expect {
expect do
described_class.new(app_proc).boot
}.not_to output.to_stderr
end.not_to output.to_stderr
ensure
Capybara.server = :default
end
Expand Down

0 comments on commit 2052ea8

Please sign in to comment.