diff --git a/capybara.gemspec b/capybara.gemspec index ce65714a..c917ec73 100644 --- a/capybara.gemspec +++ b/capybara.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.authors = ['Thomas Walpole', 'Jonas Nicklas'] s.email = ['twalpole@gmail.com', 'jonas.nicklas@gmail.com'] - s.description = 'Capybara is an integration testing tool for rack based web applications. '\ + s.description = 'Capybara is an integration testing tool for rack based web applications. ' \ 'It simulates how a user would interact with a website' s.files = Dir.glob('{lib,spec}/**/*') + %w[README.md History.md License.txt .yardopts] @@ -25,7 +25,7 @@ Gem::Specification.new do |s| 'rubygems_mfa_required' => 'true' } s.require_paths = ['lib'] - s.summary = 'Capybara aims to simplify the process of integration testing Rack applications, '\ + s.summary = 'Capybara aims to simplify the process of integration testing Rack applications, ' \ 'such as Rails, Sinatra or Merb' s.add_runtime_dependency('addressable') diff --git a/lib/capybara/queries/base_query.rb b/lib/capybara/queries/base_query.rb index a810c614..4b0a4128 100644 --- a/lib/capybara/queries/base_query.rb +++ b/lib/capybara/queries/base_query.rb @@ -79,8 +79,8 @@ module Capybara if count message << " #{occurrences count}" elsif between - message << " between #{between.begin ? between.first : 1} and" \ - " #{between.end ? between.last : 'infinite'} times" + message << " between #{between.begin ? between.first : 1} and " \ + "#{between.end ? between.last : 'infinite'} times" elsif maximum message << " at most #{occurrences maximum}" elsif minimum diff --git a/lib/capybara/queries/text_query.rb b/lib/capybara/queries/text_query.rb index 90695dab..65376456 100644 --- a/lib/capybara/queries/text_query.rb +++ b/lib/capybara/queries/text_query.rb @@ -13,7 +13,7 @@ module Capybara self.session_options = session_options if expected_text.nil? && !exact? - warn 'Checking for expected text of nil is confusing and/or pointless since it will always match. '\ + warn 'Checking for expected text of nil is confusing and/or pointless since it will always match. ' \ "Please specify a string or regexp instead. #{Capybara::Helpers.filter_backtrace(caller)}" end diff --git a/lib/capybara/selenium/nodes/firefox_node.rb b/lib/capybara/selenium/nodes/firefox_node.rb index 57775ae1..618972bc 100644 --- a/lib/capybara/selenium/nodes/firefox_node.rb +++ b/lib/capybara/selenium/nodes/firefox_node.rb @@ -11,8 +11,8 @@ class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node super rescue ::Selenium::WebDriver::Error::ElementNotInteractableError if tag_name == 'tr' - warn 'You are attempting to click a table row which has issues in geckodriver/marionette - '\ - 'see https://github.com/mozilla/geckodriver/issues/1228. Your test should probably be '\ + warn 'You are attempting to click a table row which has issues in geckodriver/marionette - ' \ + 'see https://github.com/mozilla/geckodriver/issues/1228. Your test should probably be ' \ 'clicking on a table cell like a user would. Clicking the first cell in the row instead.' return find_css('th:first-child,td:first-child')[0].click(keys, **options) end diff --git a/lib/capybara/selenium/nodes/safari_node.rb b/lib/capybara/selenium/nodes/safari_node.rb index 91fa31c7..ba48043c 100644 --- a/lib/capybara/selenium/nodes/safari_node.rb +++ b/lib/capybara/selenium/nodes/safari_node.rb @@ -11,8 +11,8 @@ class Capybara::Selenium::SafariNode < Capybara::Selenium::Node super rescue ::Selenium::WebDriver::Error::ElementNotInteractableError if tag_name == 'tr' - warn 'You are attempting to click a table row which has issues in safaridriver - '\ - 'Your test should probably be clicking on a table cell like a user would. '\ + warn 'You are attempting to click a table row which has issues in safaridriver - ' \ + 'Your test should probably be clicking on a table cell like a user would. ' \ 'Clicking the first cell in the row instead.' return find_css('th:first-child,td:first-child')[0].click(keys, **options) end diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 254dc7de..9a987196 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -412,7 +412,7 @@ module Capybara scopes.push(:frame) when :parent if scopes.last != :frame - raise Capybara::ScopeError, "`switch_to_frame(:parent)` cannot be called from inside a descendant frame's "\ + raise Capybara::ScopeError, "`switch_to_frame(:parent)` cannot be called from inside a descendant frame's " \ '`within` block.' end scopes.pop @@ -422,7 +422,7 @@ module Capybara top_level_scopes = [:frame, nil] if idx if scopes.slice(idx..).any? { |scope| !top_level_scopes.include?(scope) } - raise Capybara::ScopeError, "`switch_to_frame(:top)` cannot be called from inside a descendant frame's "\ + raise Capybara::ScopeError, "`switch_to_frame(:top)` cannot be called from inside a descendant frame's " \ '`within` block.' end scopes.slice!(idx..) @@ -514,7 +514,7 @@ module Capybara raise ArgumentError, '`switch_to_window`: either window or block should be provided' if !window && !window_locator unless scopes.last.nil? - raise Capybara::ScopeError, '`switch_to_window` is not supposed to be invoked from '\ + raise Capybara::ScopeError, '`switch_to_window` is not supposed to be invoked from ' \ '`within` or `within_frame` blocks.' end @@ -585,7 +585,7 @@ module Capybara synchronize_windows(options) do opened_handles = (driver.window_handles - old_handles) if opened_handles.size != 1 - raise Capybara::WindowError, 'block passed to #window_opened_by '\ + raise Capybara::WindowError, 'block passed to #window_opened_by ' \ "opened #{opened_handles.size} windows instead of 1" end Window.new(self, opened_handles.first) diff --git a/lib/capybara/spec/session/has_css_spec.rb b/lib/capybara/spec/session/has_css_spec.rb index b9eb03c0..5831cea2 100644 --- a/lib/capybara/spec/session/has_css_spec.rb +++ b/lib/capybara/spec/session/has_css_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +# rubocop:disable RSpec/Capybara/SpecificMatcher + Capybara::SpecHelper.spec '#has_css?' do before do @session.visit('/with_html') @@ -373,3 +375,5 @@ Capybara::SpecHelper.spec '#has_no_css?' do end end end + +# rubocop:enable RSpec/Capybara/SpecificMatcher diff --git a/spec/counter_spec.rb b/spec/counter_spec.rb index d84dc280..58f845f0 100644 --- a/spec/counter_spec.rb +++ b/spec/counter_spec.rb @@ -3,31 +3,32 @@ require 'spec_helper' RSpec.describe Capybara::Server::Middleware::Counter do - let(:counter) { Capybara::Server::Middleware::Counter.new } + let(:counter) { described_class.new } let(:uri) { '/example' } - context '#increment' do + describe '#increment' do it 'successfully' do counter.increment(uri) - expect(counter.positive?).to be true + expect(counter).to be_positive end end - context 'decrement' do + describe '#decrement' do before do counter.increment(uri) - expect(counter.positive?).to be true end context 'successfully' do it 'with same uri' do + expect(counter).to be_positive counter.decrement(uri) - expect(counter.positive?).to be false + expect(counter).not_to be_positive end it 'with changed uri' do + expect(counter).to be_positive counter.decrement('/') - expect(counter.positive?).to be false + expect(counter).not_to be_positive end end end diff --git a/spec/selenium_spec_chrome_remote.rb b/spec/selenium_spec_chrome_remote.rb index deb3d8d8..7916140d 100644 --- a/spec/selenium_spec_chrome_remote.rb +++ b/spec/selenium_spec_chrome_remote.rb @@ -21,8 +21,8 @@ def ensure_selenium_running! rescue StandardError if timer.expired? raise 'Selenium is not running. ' \ - "You can run a selenium server easily with: \n" \ - ' $ docker-compose up -d selenium_chrome' + "You can run a selenium server easily with: \n " \ + '$ docker-compose up -d selenium_chrome' else puts 'Waiting for Selenium docker instance...' sleep 1 diff --git a/spec/selenium_spec_firefox_remote.rb b/spec/selenium_spec_firefox_remote.rb index bf6a7bbe..dd61c175 100644 --- a/spec/selenium_spec_firefox_remote.rb +++ b/spec/selenium_spec_firefox_remote.rb @@ -21,8 +21,8 @@ def ensure_selenium_running! rescue StandardError if timer.expired? raise 'Selenium is not running. ' \ - "You can run a selenium server easily with: \n" \ - ' $ docker-compose up -d selenium_firefox' + "You can run a selenium server easily with: \n. " \ + '$ docker-compose up -d selenium_firefox' else puts 'Waiting for Selenium docker instance...' sleep 1