code style updates
This commit is contained in:
parent
8350c78823
commit
2528d335d4
|
@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
||||||
|
|
||||||
s.authors = ['Thomas Walpole', 'Jonas Nicklas']
|
s.authors = ['Thomas Walpole', 'Jonas Nicklas']
|
||||||
s.email = ['twalpole@gmail.com', 'jonas.nicklas@gmail.com']
|
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'
|
'It simulates how a user would interact with a website'
|
||||||
|
|
||||||
s.files = Dir.glob('{lib,spec}/**/*') + %w[README.md History.md License.txt .yardopts]
|
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'
|
'rubygems_mfa_required' => 'true'
|
||||||
}
|
}
|
||||||
s.require_paths = ['lib']
|
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'
|
'such as Rails, Sinatra or Merb'
|
||||||
|
|
||||||
s.add_runtime_dependency('addressable')
|
s.add_runtime_dependency('addressable')
|
||||||
|
|
|
@ -79,8 +79,8 @@ module Capybara
|
||||||
if count
|
if count
|
||||||
message << " #{occurrences count}"
|
message << " #{occurrences count}"
|
||||||
elsif between
|
elsif between
|
||||||
message << " between #{between.begin ? between.first : 1} and" \
|
message << " between #{between.begin ? between.first : 1} and " \
|
||||||
" #{between.end ? between.last : 'infinite'} times"
|
"#{between.end ? between.last : 'infinite'} times"
|
||||||
elsif maximum
|
elsif maximum
|
||||||
message << " at most #{occurrences maximum}"
|
message << " at most #{occurrences maximum}"
|
||||||
elsif minimum
|
elsif minimum
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Capybara
|
||||||
self.session_options = session_options
|
self.session_options = session_options
|
||||||
|
|
||||||
if expected_text.nil? && !exact?
|
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)}"
|
"Please specify a string or regexp instead. #{Capybara::Helpers.filter_backtrace(caller)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node
|
||||||
super
|
super
|
||||||
rescue ::Selenium::WebDriver::Error::ElementNotInteractableError
|
rescue ::Selenium::WebDriver::Error::ElementNotInteractableError
|
||||||
if tag_name == 'tr'
|
if tag_name == 'tr'
|
||||||
warn 'You are attempting to click a table row which has issues in geckodriver/marionette - '\
|
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 '\
|
'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.'
|
'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)
|
return find_css('th:first-child,td:first-child')[0].click(keys, **options)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,8 @@ class Capybara::Selenium::SafariNode < Capybara::Selenium::Node
|
||||||
super
|
super
|
||||||
rescue ::Selenium::WebDriver::Error::ElementNotInteractableError
|
rescue ::Selenium::WebDriver::Error::ElementNotInteractableError
|
||||||
if tag_name == 'tr'
|
if tag_name == 'tr'
|
||||||
warn 'You are attempting to click a table row which has issues in safaridriver - '\
|
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. '\
|
'Your test should probably be clicking on a table cell like a user would. ' \
|
||||||
'Clicking the first cell in the row instead.'
|
'Clicking the first cell in the row instead.'
|
||||||
return find_css('th:first-child,td:first-child')[0].click(keys, **options)
|
return find_css('th:first-child,td:first-child')[0].click(keys, **options)
|
||||||
end
|
end
|
||||||
|
|
|
@ -412,7 +412,7 @@ module Capybara
|
||||||
scopes.push(:frame)
|
scopes.push(:frame)
|
||||||
when :parent
|
when :parent
|
||||||
if scopes.last != :frame
|
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.'
|
'`within` block.'
|
||||||
end
|
end
|
||||||
scopes.pop
|
scopes.pop
|
||||||
|
@ -422,7 +422,7 @@ module Capybara
|
||||||
top_level_scopes = [:frame, nil]
|
top_level_scopes = [:frame, nil]
|
||||||
if idx
|
if idx
|
||||||
if scopes.slice(idx..).any? { |scope| !top_level_scopes.include?(scope) }
|
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.'
|
'`within` block.'
|
||||||
end
|
end
|
||||||
scopes.slice!(idx..)
|
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
|
raise ArgumentError, '`switch_to_window`: either window or block should be provided' if !window && !window_locator
|
||||||
|
|
||||||
unless scopes.last.nil?
|
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.'
|
'`within` or `within_frame` blocks.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -585,7 +585,7 @@ module Capybara
|
||||||
synchronize_windows(options) do
|
synchronize_windows(options) do
|
||||||
opened_handles = (driver.window_handles - old_handles)
|
opened_handles = (driver.window_handles - old_handles)
|
||||||
if opened_handles.size != 1
|
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"
|
"opened #{opened_handles.size} windows instead of 1"
|
||||||
end
|
end
|
||||||
Window.new(self, opened_handles.first)
|
Window.new(self, opened_handles.first)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# rubocop:disable RSpec/Capybara/SpecificMatcher
|
||||||
|
|
||||||
Capybara::SpecHelper.spec '#has_css?' do
|
Capybara::SpecHelper.spec '#has_css?' do
|
||||||
before do
|
before do
|
||||||
@session.visit('/with_html')
|
@session.visit('/with_html')
|
||||||
|
@ -373,3 +375,5 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:enable RSpec/Capybara/SpecificMatcher
|
||||||
|
|
|
@ -3,31 +3,32 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
RSpec.describe Capybara::Server::Middleware::Counter do
|
RSpec.describe Capybara::Server::Middleware::Counter do
|
||||||
let(:counter) { Capybara::Server::Middleware::Counter.new }
|
let(:counter) { described_class.new }
|
||||||
let(:uri) { '/example' }
|
let(:uri) { '/example' }
|
||||||
|
|
||||||
context '#increment' do
|
describe '#increment' do
|
||||||
it 'successfully' do
|
it 'successfully' do
|
||||||
counter.increment(uri)
|
counter.increment(uri)
|
||||||
expect(counter.positive?).to be true
|
expect(counter).to be_positive
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'decrement' do
|
describe '#decrement' do
|
||||||
before do
|
before do
|
||||||
counter.increment(uri)
|
counter.increment(uri)
|
||||||
expect(counter.positive?).to be true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'successfully' do
|
context 'successfully' do
|
||||||
it 'with same uri' do
|
it 'with same uri' do
|
||||||
|
expect(counter).to be_positive
|
||||||
counter.decrement(uri)
|
counter.decrement(uri)
|
||||||
expect(counter.positive?).to be false
|
expect(counter).not_to be_positive
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'with changed uri' do
|
it 'with changed uri' do
|
||||||
|
expect(counter).to be_positive
|
||||||
counter.decrement('/')
|
counter.decrement('/')
|
||||||
expect(counter.positive?).to be false
|
expect(counter).not_to be_positive
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,8 +21,8 @@ def ensure_selenium_running!
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
if timer.expired?
|
if timer.expired?
|
||||||
raise 'Selenium is not running. ' \
|
raise 'Selenium is not running. ' \
|
||||||
"You can run a selenium server easily with: \n" \
|
"You can run a selenium server easily with: \n " \
|
||||||
' $ docker-compose up -d selenium_chrome'
|
'$ docker-compose up -d selenium_chrome'
|
||||||
else
|
else
|
||||||
puts 'Waiting for Selenium docker instance...'
|
puts 'Waiting for Selenium docker instance...'
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
|
@ -21,8 +21,8 @@ def ensure_selenium_running!
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
if timer.expired?
|
if timer.expired?
|
||||||
raise 'Selenium is not running. ' \
|
raise 'Selenium is not running. ' \
|
||||||
"You can run a selenium server easily with: \n" \
|
"You can run a selenium server easily with: \n. " \
|
||||||
' $ docker-compose up -d selenium_firefox'
|
'$ docker-compose up -d selenium_firefox'
|
||||||
else
|
else
|
||||||
puts 'Waiting for Selenium docker instance...'
|
puts 'Waiting for Selenium docker instance...'
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
Loading…
Reference in New Issue