mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
code style updates
This commit is contained in:
parent
8350c78823
commit
2528d335d4
10 changed files with 29 additions and 24 deletions
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue