mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Drop dupport for EOL'd Ruby 2.6
This commit is contained in:
parent
d05ae5c595
commit
614274b1a5
38 changed files with 143 additions and 164 deletions
|
@ -7,7 +7,7 @@ require:
|
|||
AllCops:
|
||||
NewCops: enable
|
||||
DisabledByDefault: false
|
||||
TargetRubyVersion: 2.6
|
||||
TargetRubyVersion: 2.7
|
||||
Exclude:
|
||||
- 'vendor/**/*'
|
||||
- 'gemfiles/vendor/**/*'
|
||||
|
@ -20,7 +20,7 @@ Layout/LineLength:
|
|||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- 'lib/capybara/spec/**/*'
|
||||
IgnoredPatterns:
|
||||
AllowedPatterns:
|
||||
- '\s+# _?rubocop'
|
||||
- '^\s*#'
|
||||
- '^\s*(raise|warn|Capybara::Helpers.warn) '
|
||||
|
@ -138,7 +138,7 @@ Layout/FirstArrayElementIndentation:
|
|||
EnforcedStyle: consistent
|
||||
|
||||
Layout/IndentationWidth:
|
||||
IgnoredPatterns: ['^\s*module']
|
||||
AllowedPatterns: ['^\s*module']
|
||||
|
||||
Security/YAMLLoad:
|
||||
Exclude:
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
# Version 3.37.0
|
||||
Release date: unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
* Ruby 2.7.0+ is now required
|
||||
|
||||
# Version 3.36.0
|
||||
Release date: 2021-10-24
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|||
|
||||
## <a name="setup"></a>Setup
|
||||
|
||||
Capybara requires Ruby 2.6.0 or later. To install, add this line to your
|
||||
Capybara requires Ruby 2.7.0 or later. To install, add this line to your
|
||||
`Gemfile` and run `bundle install`:
|
||||
|
||||
```ruby
|
||||
|
|
10
Rakefile
10
Rakefile
|
@ -52,15 +52,15 @@ end
|
|||
|
||||
desc 'Task for running CI'
|
||||
task :travis do
|
||||
if ENV['CAPYBARA_REMOTE'] && ENV['CAPYBARA_FF']
|
||||
if ENV.fetch('CAPYBARA_REMOTE', nil) && ENV.fetch('CAPYBARA_FF', nil)
|
||||
Rake::Task[:spec_firefox_remote].invoke
|
||||
elsif ENV['CAPYBARA_FF']
|
||||
elsif ENV.fetch('CAPYBARA_FF', nil)
|
||||
Rake::Task[:spec_firefox].invoke
|
||||
elsif ENV['CAPYBARA_IE']
|
||||
elsif ENV.fetch('CAPYBARA_IE', nil)
|
||||
Rake::Task[:spec_ie].invoke
|
||||
elsif ENV['CAPYBARA_EDGE']
|
||||
elsif ENV.fetch('CAPYBARA_EDGE', nil)
|
||||
Rake::Task[:spec_edge].invoke
|
||||
elsif ENV['CAPYBARA_REMOTE']
|
||||
elsif ENV.fetch('CAPYBARA_REMOTE', nil)
|
||||
Rake::Task[:spec_chrome_remote].invoke
|
||||
else
|
||||
Rake::Task[:spec_chrome].invoke
|
||||
|
|
|
@ -8,7 +8,7 @@ require 'capybara/version'
|
|||
Gem::Specification.new do |s|
|
||||
s.name = 'capybara'
|
||||
s.version = Capybara::VERSION
|
||||
s.required_ruby_version = '>= 2.6.0'
|
||||
s.required_ruby_version = '>= 2.7.0'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.authors = ['Thomas Walpole', 'Jonas Nicklas']
|
||||
|
@ -21,7 +21,8 @@ Gem::Specification.new do |s|
|
|||
s.homepage = 'https://github.com/teamcapybara/capybara'
|
||||
s.metadata = {
|
||||
'changelog_uri' => 'https://github.com/teamcapybara/capybara/blob/master/History.md',
|
||||
'source_code_uri' => 'https://github.com/teamcapybara/capybara'
|
||||
'source_code_uri' => 'https://github.com/teamcapybara/capybara',
|
||||
'rubygems_mfa_required' => 'true'
|
||||
}
|
||||
s.require_paths = ['lib']
|
||||
s.summary = 'Capybara aims to simplify the process of integration testing Rack applications, '\
|
||||
|
|
|
@ -47,17 +47,11 @@ module Capybara
|
|||
end
|
||||
|
||||
Session::DSL_METHODS.each do |method|
|
||||
if RUBY_VERSION >= '2.7'
|
||||
class_eval <<~METHOD, __FILE__, __LINE__ + 1
|
||||
def #{method}(...)
|
||||
page.method("#{method}").call(...)
|
||||
end
|
||||
METHOD
|
||||
else
|
||||
define_method method do |*args, &block|
|
||||
page.send method, *args, &block
|
||||
class_eval <<~METHOD, __FILE__, __LINE__ + 1
|
||||
def #{method}(...)
|
||||
page.method("#{method}").call(...)
|
||||
end
|
||||
end
|
||||
METHOD
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -246,9 +246,9 @@ module Capybara
|
|||
|
||||
##
|
||||
# @deprecated
|
||||
def must_have_style(*args, **kw_args, &block)
|
||||
def must_have_style(...)
|
||||
warn 'must_have_style is deprecated, please use must_match_style'
|
||||
must_match_style(*args, **kw_args, &block)
|
||||
must_match_style(...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -115,7 +115,7 @@ module Capybara
|
|||
#
|
||||
# @return [Capybara::Node::Element] The element
|
||||
def set(value, **options)
|
||||
if ENV['CAPYBARA_THOROUGH'] && readonly?
|
||||
if ENV.fetch('CAPYBARA_THOROUGH', nil) && readonly?
|
||||
raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}"
|
||||
end
|
||||
|
||||
|
|
|
@ -98,10 +98,10 @@ class Capybara::RackTest::Driver < Capybara::Driver::Base
|
|||
@browser = nil
|
||||
end
|
||||
|
||||
def get(*args, &block); browser.get(*args, &block); end
|
||||
def post(*args, &block); browser.post(*args, &block); end
|
||||
def put(*args, &block); browser.put(*args, &block); end
|
||||
def delete(*args, &block); browser.delete(*args, &block); end
|
||||
def get(...); browser.get(...); end
|
||||
def post(...); browser.post(...); end
|
||||
def put(...); browser.put(...); end
|
||||
def delete(...); browser.delete(...); end
|
||||
def header(key, value); browser.header(key, value); end
|
||||
|
||||
def invalid_element_errors
|
||||
|
|
|
@ -19,9 +19,6 @@ module Capybara
|
|||
def method_missing(method_name, *args, **options, &block)
|
||||
if @registered.respond_to?(method_name)
|
||||
Capybara::Helpers.warn "DEPRECATED: Calling '#{method_name}' on the drivers/servers container is deprecated without replacement"
|
||||
# RUBY 2.6 will send an empty hash rather than nothing with **options so fix that
|
||||
return @registered.public_send(method_name, *args, &block) if options.empty?
|
||||
|
||||
return @registered.public_send(method_name, *args, **options, &block)
|
||||
end
|
||||
super
|
||||
|
|
|
@ -15,36 +15,36 @@ module Capybara
|
|||
# RSpec matcher for whether the element(s) matching a given selector exist.
|
||||
#
|
||||
# @see Capybara::Node::Matchers#assert_selector
|
||||
def have_selector(*args, **kw_args, &optional_filter_block)
|
||||
Matchers::HaveSelector.new(*args, **kw_args, &optional_filter_block)
|
||||
def have_selector(...)
|
||||
Matchers::HaveSelector.new(...)
|
||||
end
|
||||
|
||||
# RSpec matcher for whether the element(s) matching a group of selectors exist.
|
||||
#
|
||||
# @see Capybara::Node::Matchers#assert_all_of_selectors
|
||||
def have_all_of_selectors(*args, **kw_args, &optional_filter_block)
|
||||
Matchers::HaveAllSelectors.new(*args, **kw_args, &optional_filter_block)
|
||||
def have_all_of_selectors(...)
|
||||
Matchers::HaveAllSelectors.new(...)
|
||||
end
|
||||
|
||||
# RSpec matcher for whether no element(s) matching a group of selectors exist.
|
||||
#
|
||||
# @see Capybara::Node::Matchers#assert_none_of_selectors
|
||||
def have_none_of_selectors(*args, **kw_args, &optional_filter_block)
|
||||
Matchers::HaveNoSelectors.new(*args, **kw_args, &optional_filter_block)
|
||||
def have_none_of_selectors(...)
|
||||
Matchers::HaveNoSelectors.new(...)
|
||||
end
|
||||
|
||||
# RSpec matcher for whether the element(s) matching any of a group of selectors exist.
|
||||
#
|
||||
# @see Capybara::Node::Matchers#assert_any_of_selectors
|
||||
def have_any_of_selectors(*args, **kw_args, &optional_filter_block)
|
||||
Matchers::HaveAnySelectors.new(*args, **kw_args, &optional_filter_block)
|
||||
def have_any_of_selectors(...)
|
||||
Matchers::HaveAnySelectors.new(...)
|
||||
end
|
||||
|
||||
# RSpec matcher for whether the current element matches a given selector.
|
||||
#
|
||||
# @see Capybara::Node::Matchers#assert_matches_selector
|
||||
def match_selector(*args, **kw_args, &optional_filter_block)
|
||||
Matchers::MatchSelector.new(*args, **kw_args, &optional_filter_block)
|
||||
def match_selector(...)
|
||||
Matchers::MatchSelector.new(...)
|
||||
end
|
||||
|
||||
%i[css xpath].each do |selector|
|
||||
|
@ -177,15 +177,15 @@ module Capybara
|
|||
# RSpec matcher for whether sibling element(s) matching a given selector exist.
|
||||
#
|
||||
# @see Capybara::Node::Matchers#assert_sibling
|
||||
def have_sibling(*args, **kw_args, &optional_filter_block)
|
||||
Matchers::HaveSibling.new(*args, **kw_args, &optional_filter_block)
|
||||
def have_sibling(...)
|
||||
Matchers::HaveSibling.new(...)
|
||||
end
|
||||
|
||||
# RSpec matcher for whether ancestor element(s) matching a given selector exist.
|
||||
#
|
||||
# @see Capybara::Node::Matchers#assert_ancestor
|
||||
def have_ancestor(*args, **kw_args, &optional_filter_block)
|
||||
Matchers::HaveAncestor.new(*args, **kw_args, &optional_filter_block)
|
||||
def have_ancestor(...)
|
||||
Matchers::HaveAncestor.new(...)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -8,10 +8,10 @@ module Capybara
|
|||
class HaveSelector < CountableWrappedElementMatcher
|
||||
def initialize(*args, **kw_args, &filter_block)
|
||||
super
|
||||
if (RUBY_VERSION >= '2.7') && (@args.size < 2) && @kw_args.keys.any?(String) # rubocop:disable Style/GuardClause
|
||||
@args.push(@kw_args)
|
||||
@kw_args = {}
|
||||
end
|
||||
return unless (@args.size < 2) && @kw_args.keys.any?(String)
|
||||
|
||||
@args.push(@kw_args)
|
||||
@kw_args = {}
|
||||
end
|
||||
|
||||
def element_matches?(el)
|
||||
|
|
|
@ -261,7 +261,8 @@ module Capybara
|
|||
def parameter_names(block)
|
||||
key_types = %i[key keyreq]
|
||||
# user filter_map when we drop dupport for 2.6
|
||||
block.parameters.select { |(type, _name)| key_types.include? type }.map { |(_, name)| name }
|
||||
# block.parameters.select { |(type, _name)| key_types.include? type }.map { |(_, name)| name }
|
||||
block.parameters.filter_map { |(type, name)| name if key_types.include? type }
|
||||
end
|
||||
|
||||
def expression(type, allowed_filters, &block)
|
||||
|
|
|
@ -765,33 +765,20 @@ module Capybara
|
|||
end
|
||||
|
||||
NODE_METHODS.each do |method|
|
||||
if RUBY_VERSION >= '2.7'
|
||||
class_eval <<~METHOD, __FILE__, __LINE__ + 1
|
||||
def #{method}(...)
|
||||
@touched = true
|
||||
current_scope.#{method}(...)
|
||||
end
|
||||
METHOD
|
||||
else
|
||||
define_method method do |*args, &block|
|
||||
class_eval <<~METHOD, __FILE__, __LINE__ + 1
|
||||
def #{method}(...)
|
||||
@touched = true
|
||||
current_scope.send(method, *args, &block)
|
||||
current_scope.#{method}(...)
|
||||
end
|
||||
end
|
||||
METHOD
|
||||
end
|
||||
|
||||
DOCUMENT_METHODS.each do |method|
|
||||
if RUBY_VERSION >= '2.7'
|
||||
class_eval <<~METHOD, __FILE__, __LINE__ + 1
|
||||
def #{method}(...)
|
||||
document.#{method}(...)
|
||||
end
|
||||
METHOD
|
||||
else
|
||||
define_method method do |*args, &block|
|
||||
document.send(method, *args, &block)
|
||||
class_eval <<~METHOD, __FILE__, __LINE__ + 1
|
||||
def #{method}(...)
|
||||
document.#{method}(...)
|
||||
end
|
||||
end
|
||||
METHOD
|
||||
end
|
||||
|
||||
def inspect
|
||||
|
|
|
@ -132,7 +132,7 @@ Capybara::SpecHelper.spec '#all' do
|
|||
it 'should use the sessions ignore_hidden_elements', psc: true do
|
||||
Capybara.ignore_hidden_elements = true
|
||||
@session.config.ignore_hidden_elements = false
|
||||
expect(Capybara.ignore_hidden_elements).to eq(true)
|
||||
expect(Capybara.ignore_hidden_elements).to be(true)
|
||||
expect(@session.all(:css, 'a.simple').size).to eq(2)
|
||||
@session.config.ignore_hidden_elements = true
|
||||
expect(@session.all(:css, 'a.simple').size).to eq(1)
|
||||
|
@ -208,12 +208,10 @@ Capybara::SpecHelper.spec '#all' do
|
|||
expect { @session.all(:css, 'h1, p', between: 5..) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
|
||||
eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.6
|
||||
it'treats a beginless range as maximum' do
|
||||
expect { @session.all(:css, 'h1, p', between: ..7) }.not_to raise_error
|
||||
expect { @session.all(:css, 'h1, p', between: ..3) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
TEST
|
||||
it 'treats a beginless range as maximum' do
|
||||
expect { @session.all(:css, 'h1, p', between: ..7) }.not_to raise_error
|
||||
expect { @session.all(:css, 'h1, p', between: ..3) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple count filters' do
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
Capybara::SpecHelper.spec '#assert_text' do
|
||||
it 'should be true if the given text is on the page' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text('est')).to eq(true)
|
||||
expect(@session.assert_text('Lorem')).to eq(true)
|
||||
expect(@session.assert_text('Redirect')).to eq(true)
|
||||
expect(@session.assert_text(:Redirect)).to eq(true)
|
||||
expect(@session.assert_text('text with whitespace')).to eq(true)
|
||||
expect(@session.assert_text('est')).to be(true)
|
||||
expect(@session.assert_text('Lorem')).to be(true)
|
||||
expect(@session.assert_text('Redirect')).to be(true)
|
||||
expect(@session.assert_text(:Redirect)).to be(true)
|
||||
expect(@session.assert_text('text with whitespace')).to be(true)
|
||||
end
|
||||
|
||||
it 'should support collapsing whitespace' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text('text with whitespace', normalize_ws: true)).to eq(true)
|
||||
expect(@session.assert_text('text with whitespace', normalize_ws: true)).to be(true)
|
||||
end
|
||||
|
||||
context 'with enabled default collapsing whitespace' do
|
||||
|
@ -20,19 +20,19 @@ Capybara::SpecHelper.spec '#assert_text' do
|
|||
|
||||
it 'should be true if the given unnormalized text is on the page' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text('text with whitespace', normalize_ws: false)).to eq(true)
|
||||
expect(@session.assert_text('text with whitespace', normalize_ws: false)).to be(true)
|
||||
end
|
||||
|
||||
it 'should support collapsing whitespace' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text('text with whitespace')).to eq(true)
|
||||
expect(@session.assert_text('text with whitespace')).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should take scopes into account' do
|
||||
@session.visit('/with_html')
|
||||
@session.within("//a[@title='awesome title']") do
|
||||
expect(@session.assert_text('labore')).to eq(true)
|
||||
expect(@session.assert_text('labore')).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,13 +47,13 @@ Capybara::SpecHelper.spec '#assert_text' do
|
|||
|
||||
it 'should be true if :all given and text is invisible.' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text(:all, 'Some of this text is hidden!')).to eq(true)
|
||||
expect(@session.assert_text(:all, 'Some of this text is hidden!')).to be(true)
|
||||
end
|
||||
|
||||
it 'should be true if `Capybara.ignore_hidden_elements = true` and text is invisible.' do
|
||||
Capybara.ignore_hidden_elements = false
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text('Some of this text is hidden!')).to eq(true)
|
||||
expect(@session.assert_text('Some of this text is hidden!')).to be(true)
|
||||
end
|
||||
|
||||
it 'should raise error with a helpful message if the requested text is present but invisible' do
|
||||
|
@ -88,7 +88,7 @@ Capybara::SpecHelper.spec '#assert_text' do
|
|||
|
||||
it 'should be true if the text in the page matches given regexp' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text(/Lorem/)).to eq(true)
|
||||
expect(@session.assert_text(/Lorem/)).to be(true)
|
||||
end
|
||||
|
||||
it "should raise error if the text in the page doesn't match given regexp" do
|
||||
|
@ -109,13 +109,13 @@ Capybara::SpecHelper.spec '#assert_text' do
|
|||
Capybara.default_max_wait_time = 2
|
||||
@session.visit('/with_js')
|
||||
@session.click_link('Click me')
|
||||
expect(@session.assert_text('Has been clicked')).to eq(true)
|
||||
expect(@session.assert_text('Has been clicked')).to be(true)
|
||||
end
|
||||
|
||||
context 'with between' do
|
||||
it 'should be true if the text occurs within the range given' do
|
||||
@session.visit('/with_count')
|
||||
expect(@session.assert_text('count', between: 1..3)).to eq(true)
|
||||
expect(@session.assert_text('count', between: 1..3)).to be(true)
|
||||
end
|
||||
|
||||
it 'should be false if the text occurs more or fewer times than range' do
|
||||
|
@ -203,13 +203,13 @@ Capybara::SpecHelper.spec '#assert_no_text' do
|
|||
it 'should be true if scoped to an element which does not have the text' do
|
||||
@session.visit('/with_html')
|
||||
@session.within("//a[@title='awesome title']") do
|
||||
expect(@session.assert_no_text('monkey')).to eq(true)
|
||||
expect(@session.assert_no_text('monkey')).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should be true if the given text is on the page but not visible' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_no_text('Inside element with hidden ancestor')).to eq(true)
|
||||
expect(@session.assert_no_text('Inside element with hidden ancestor')).to be(true)
|
||||
end
|
||||
|
||||
it 'should raise error if :all given and text is invisible.' do
|
||||
|
@ -236,7 +236,7 @@ Capybara::SpecHelper.spec '#assert_no_text' do
|
|||
context 'with count' do
|
||||
it 'should be true if the text occurs within the range given' do
|
||||
@session.visit('/with_count')
|
||||
expect(@session.assert_text('count', count: 2)).to eq(true)
|
||||
expect(@session.assert_text('count', count: 2)).to be(true)
|
||||
end
|
||||
|
||||
it 'should be false if the text occurs more or fewer times than range' do
|
||||
|
|
|
@ -16,8 +16,8 @@ Capybara::SpecHelper.spec '#has_current_path?' do
|
|||
|
||||
it 'should not raise an error when non-http' do
|
||||
@session.reset_session!
|
||||
expect(@session.has_current_path?(/monkey/)).to eq false
|
||||
expect(@session.has_current_path?('/with_js')).to eq false
|
||||
expect(@session.has_current_path?(/monkey/)).to be false
|
||||
expect(@session.has_current_path?('/with_js')).to be false
|
||||
end
|
||||
|
||||
it 'should handle non-escaped query options' do
|
||||
|
|
|
@ -383,7 +383,7 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|||
end
|
||||
|
||||
it 'should support locator-less usage' do
|
||||
expect(@session.has_no_unchecked_field?(disabled: false, id: 'form_disabled_unchecked_checkbox')).to eq true
|
||||
expect(@session.has_no_unchecked_field?(disabled: false, id: 'form_disabled_unchecked_checkbox')).to be true
|
||||
expect(@session).to have_no_unchecked_field(disabled: false, id: 'form_disabled_unchecked_checkbox')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -180,9 +180,9 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|||
end
|
||||
|
||||
it 'should support locator-less usage' do
|
||||
expect(@session.has_select?(with_options: %w[Norway Sweden])).to eq true
|
||||
expect(@session.has_select?(with_options: %w[Norway Sweden])).to be true
|
||||
expect(@session).to have_select(with_options: ['London'])
|
||||
expect(@session.has_select?(with_selected: %w[Commando Boxerbriefs])).to eq true
|
||||
expect(@session.has_select?(with_selected: %w[Commando Boxerbriefs])).to be true
|
||||
expect(@session).to have_select(with_selected: ['Briefs'])
|
||||
end
|
||||
end
|
||||
|
@ -302,9 +302,9 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|||
end
|
||||
|
||||
it 'should support locator-less usage' do
|
||||
expect(@session.has_no_select?(with_options: %w[Norway Sweden Finland Latvia])).to eq true
|
||||
expect(@session.has_no_select?(with_options: %w[Norway Sweden Finland Latvia])).to be true
|
||||
expect(@session).to have_no_select(with_options: ['New London'])
|
||||
expect(@session.has_no_select?(id: 'form_underwear', with_selected: ['Boxers'])).to eq true
|
||||
expect(@session.has_no_select?(id: 'form_underwear', with_selected: ['Boxers'])).to be true
|
||||
expect(@session).to have_no_select(id: 'form_underwear', with_selected: %w[Commando Boxers])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -127,11 +127,7 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|||
def to_hash; { value: 'Other hash' } end
|
||||
end.new
|
||||
@session.visit('/with_html')
|
||||
if RUBY_VERSION >= '2.7'
|
||||
expect(@session).to have_text(:visible, with_to_hash, **{})
|
||||
else
|
||||
expect(@session).to have_text(:visible, with_to_hash, {})
|
||||
end
|
||||
expect(@session).to have_text(:visible, with_to_hash, **{})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|||
it 'should return false if window is closed' do
|
||||
@session.switch_to_window(other_window)
|
||||
other_window.close
|
||||
expect(other_window.current?).to eq(false)
|
||||
expect(other_window.current?).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Capybara
|
||||
VERSION = '3.36.0'
|
||||
VERSION = '3.37.0'
|
||||
end
|
||||
|
|
|
@ -118,7 +118,7 @@ module Capybara
|
|||
alias_method :==, :eql?
|
||||
|
||||
def hash
|
||||
@session.hash ^ @handle.hash
|
||||
[@session, @handle].hash
|
||||
end
|
||||
|
||||
def inspect
|
||||
|
|
|
@ -115,7 +115,7 @@ RSpec.describe Capybara::DSL do
|
|||
it 'should yield the passed block' do
|
||||
called = false
|
||||
Capybara.using_driver(:selenium) { called = true }
|
||||
expect(called).to eq(true)
|
||||
expect(called).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -220,7 +220,7 @@ RSpec.describe Capybara::DSL do
|
|||
it 'should yield the passed block' do
|
||||
called = false
|
||||
Capybara.using_session(:administrator) { called = true }
|
||||
expect(called).to eq(true)
|
||||
expect(called).to be(true)
|
||||
end
|
||||
|
||||
it 'should be nestable' do
|
||||
|
|
|
@ -5,9 +5,9 @@ require 'selenium-webdriver'
|
|||
|
||||
RSpec.describe Capybara::Selenium::Driver do
|
||||
it 'should exit with a non-zero exit status' do
|
||||
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
||||
options = { browser: ENV.fetch('SELENIUM_BROWSER', :firefox).to_sym }
|
||||
browser = described_class.new(TestApp, options).browser
|
||||
expect(browser).to be_truthy
|
||||
expect(true).to eq(false) # rubocop:disable RSpec/ExpectActual
|
||||
expect(true).to be(false) # rubocop:disable RSpec/ExpectActual
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,9 +5,9 @@ require 'selenium-webdriver'
|
|||
|
||||
RSpec.describe Capybara::Selenium::Driver do
|
||||
it 'should exit with a zero exit status' do
|
||||
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
||||
options = { browser: ENV.fetch('SELENIUM_BROWSER', :firefox).to_sym }
|
||||
browser = described_class.new(TestApp, **options).browser
|
||||
expect(browser).to be_truthy
|
||||
expect(true).to eq(true) # rubocop:disable RSpec/ExpectActual,RSpec/IdenticalEqualityAssertion
|
||||
expect(true).to be(true) # rubocop:disable RSpec/ExpectActual,RSpec/IdenticalEqualityAssertion
|
||||
end
|
||||
end
|
||||
|
|
|
@ -219,7 +219,7 @@ RSpec.describe Capybara::RackTest::Driver do
|
|||
it 'should not include fragments in the referer header' do
|
||||
driver.visit('/header_links#an-anchor')
|
||||
driver.find_xpath('.//input').first.click
|
||||
expect(driver.request.get_header("HTTP_REFERER")).to eq('http://www.example.com/header_links')
|
||||
expect(driver.request.get_header('HTTP_REFERER')).to eq('http://www.example.com/header_links')
|
||||
end
|
||||
|
||||
it 'is possible to not follow redirects' do
|
||||
|
|
|
@ -86,25 +86,23 @@ RSpec.describe Capybara::Result do
|
|||
expect(result[2..].map(&:text)).to eq %w[Gamma Delta]
|
||||
end
|
||||
|
||||
eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.6
|
||||
it 'supports inclusive positive beginless ranges' do
|
||||
expect(result[..2].map(&:text)).to eq %w[Alpha Beta Gamma]
|
||||
end
|
||||
it 'supports inclusive positive beginless ranges' do
|
||||
expect(result[..2].map(&:text)).to eq %w[Alpha Beta Gamma]
|
||||
end
|
||||
|
||||
it 'supports inclusive negative beginless ranges' do
|
||||
expect(result[..-2].map(&:text)).to eq %w[Alpha Beta Gamma]
|
||||
expect(result[..-1].map(&:text)).to eq %w[Alpha Beta Gamma Delta]
|
||||
end
|
||||
it 'supports inclusive negative beginless ranges' do
|
||||
expect(result[..-2].map(&:text)).to eq %w[Alpha Beta Gamma]
|
||||
expect(result[..-1].map(&:text)).to eq %w[Alpha Beta Gamma Delta]
|
||||
end
|
||||
|
||||
it 'supports exclusive positive beginless ranges' do
|
||||
expect(result[...2].map(&:text)).to eq %w[Alpha Beta]
|
||||
end
|
||||
it 'supports exclusive positive beginless ranges' do
|
||||
expect(result[...2].map(&:text)).to eq %w[Alpha Beta]
|
||||
end
|
||||
|
||||
it 'supports exclusive negative beginless ranges' do
|
||||
expect(result[...-2].map(&:text)).to eq %w[Alpha Beta]
|
||||
expect(result[...-1].map(&:text)).to eq %w[Alpha Beta Gamma]
|
||||
end
|
||||
TEST
|
||||
it 'supports exclusive negative beginless ranges' do
|
||||
expect(result[...-2].map(&:text)).to eq %w[Alpha Beta]
|
||||
expect(result[...-1].map(&:text)).to eq %w[Alpha Beta Gamma]
|
||||
end
|
||||
|
||||
it 'works with filter blocks' do
|
||||
result = string.all('//li') { |node| node.text == 'Alpha' }
|
||||
|
@ -115,52 +113,52 @@ RSpec.describe Capybara::Result do
|
|||
it 'should evaluate filters lazily for idx' do
|
||||
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
||||
# Not processed until accessed
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 0
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 0
|
||||
|
||||
# Only one retrieved when needed
|
||||
result.first
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 1
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 1
|
||||
|
||||
# works for indexed access
|
||||
result[0]
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 1
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 1
|
||||
|
||||
result[2]
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 3
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 3
|
||||
|
||||
# All cached when converted to array
|
||||
result.to_a
|
||||
expect(result.instance_variable_get('@result_cache').size).to eq 4
|
||||
expect(result.instance_variable_get(:@result_cache).size).to eq 4
|
||||
end
|
||||
|
||||
it 'should evaluate filters lazily for range' do
|
||||
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
||||
result[0..1]
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 2
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 2
|
||||
|
||||
expect(result[0..7].size).to eq 4
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 4
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 4
|
||||
end
|
||||
|
||||
it 'should evaluate filters lazily for idx and length' do
|
||||
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
||||
result[1, 2]
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 3
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 3
|
||||
|
||||
expect(result[2, 5].size).to eq 2
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 4
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 4
|
||||
end
|
||||
|
||||
it 'should only need to evaluate one result for any?' do
|
||||
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
||||
result.any?
|
||||
expect(result.instance_variable_get('@result_cache').size).to be 1
|
||||
expect(result.instance_variable_get(:@result_cache).size).to be 1
|
||||
end
|
||||
|
||||
it 'should evaluate all elements when #to_a called' do
|
||||
# All cached when converted to array
|
||||
result.to_a
|
||||
expect(result.instance_variable_get('@result_cache').size).to eq 4
|
||||
expect(result.instance_variable_get(:@result_cache).size).to eq 4
|
||||
end
|
||||
|
||||
describe '#each' do
|
||||
|
@ -169,7 +167,7 @@ RSpec.describe Capybara::Result do
|
|||
results = []
|
||||
result.each do |el|
|
||||
results << el
|
||||
expect(result.instance_variable_get('@result_cache').size).to eq results.size
|
||||
expect(result.instance_variable_get(:@result_cache).size).to eq results.size
|
||||
end
|
||||
|
||||
expect(results.size).to eq 4
|
||||
|
@ -183,7 +181,7 @@ RSpec.describe Capybara::Result do
|
|||
it 'lazily evaluates' do
|
||||
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
||||
result.each.with_index do |_el, idx|
|
||||
expect(result.instance_variable_get('@result_cache').size).to eq(idx + 1) # 0 indexing
|
||||
expect(result.instance_variable_get(:@result_cache).size).to eq(idx + 1) # 0 indexing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,11 +91,11 @@ end
|
|||
|
||||
ffeature 'if ffeature aliases focused tag then' do # rubocop:disable RSpec/Focus
|
||||
scenario 'scenario inside this feature has metatag focus tag' do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
expect(example.metadata[:focus]).to be true
|
||||
end
|
||||
|
||||
scenario 'other scenarios also has metatag focus tag' do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
expect(example.metadata[:focus]).to be true
|
||||
end
|
||||
end
|
||||
# rubocop:enable RSpec/RepeatedExample, RSpec/MultipleDescribes
|
||||
|
|
|
@ -11,7 +11,7 @@ end
|
|||
|
||||
feature 'if fscenario aliases focused tag then' do
|
||||
fscenario 'scenario should have focused meta tag' do |example| # rubocop:disable RSpec/Focus
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
expect(example.metadata[:focus]).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ Capybara.register_driver :sauce_chrome do |app|
|
|||
browser_name: 'chrome',
|
||||
version: '65.0',
|
||||
name: 'Capybara test',
|
||||
build: ENV['TRAVIS_REPO_SLUG'] || "Ruby-RSpec-Selenium: Local-#{Time.now.to_i}",
|
||||
username: ENV['SAUCE_USERNAME'],
|
||||
access_key: ENV['SAUCE_ACCESS_KEY']
|
||||
build: ENV.fetch('TRAVIS_REPO_SLUG', "Ruby-RSpec-Selenium: Local-#{Time.now.to_i}"),
|
||||
username: ENV.fetch('SAUCE_USERNAME', nil),
|
||||
access_key: ENV.fetch('SAUCE_ACCESS_KEY', nil)
|
||||
}
|
||||
|
||||
options.delete(:browser_name)
|
||||
|
|
|
@ -159,7 +159,7 @@ RSpec.describe Capybara do
|
|||
end
|
||||
|
||||
it 'returns nil if no match' do
|
||||
expect(Capybara::Selector.for('nothing')).to be nil
|
||||
expect(Capybara::Selector.for('nothing')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ require 'rspec/shared_spec_matchers'
|
|||
|
||||
CHROME_DRIVER = :selenium_chrome
|
||||
|
||||
Selenium::WebDriver::Chrome.path = '/usr/bin/google-chrome-beta' if ENV['CI'] && ENV['CHROME_BETA']
|
||||
Selenium::WebDriver::Chrome.path = '/usr/bin/google-chrome-beta' if ENV.fetch('CI', nil) && ENV.fetch('CHROME_BETA', nil)
|
||||
|
||||
browser_options = ::Selenium::WebDriver::Chrome::Options.new
|
||||
browser_options.headless! if ENV['HEADLESS']
|
||||
|
|
|
@ -103,7 +103,7 @@ RSpec.describe 'Capybara::Session with firefox' do # rubocop:disable RSpec/Multi
|
|||
end
|
||||
|
||||
it 'should fill in a datetime input with a String' do
|
||||
pending "Need to figure out what string format this will actually accept"
|
||||
pending 'Need to figure out what string format this will actually accept'
|
||||
session.fill_in('form_datetime', with: datetime.iso8601)
|
||||
session.click_button('awesome')
|
||||
expect(Time.parse(extract_results(session)['datetime'])).to eq datetime
|
||||
|
|
|
@ -80,7 +80,7 @@ Capybara::SpecHelper.run_specs TestSessions::Safari, SAFARI_DRIVER.to_s, capybar
|
|||
when 'Capybara::Session selenium_safari node #double_click should allow modifiers'
|
||||
pending "safaridriver doesn't generate double click with key modifiers"
|
||||
when /when w3c_click_offset is true should offset/
|
||||
pending "w3c_click_offset is not currently supported with safaridriver"
|
||||
pending 'w3c_click_offset is not currently supported with safaridriver'
|
||||
when 'Capybara::Session selenium_safari #go_back should fetch a response from the driver from the previous page',
|
||||
'Capybara::Session selenium_safari #go_forward should fetch a response from the driver from the previous page'
|
||||
skip 'safaridriver loses the ability to find elements in the document after `go_back`'
|
||||
|
|
|
@ -20,7 +20,7 @@ RSpec.describe Capybara::Server do
|
|||
|
||||
it 'should bind to the specified host' do
|
||||
# TODO: travis with jruby in container mode has an issue with this test
|
||||
skip 'This platform has an issue with this test' if (ENV['TRAVIS'] && (RUBY_ENGINE == 'jruby')) || Gem.win_platform?
|
||||
skip 'This platform has an issue with this test' if (ENV.fetch('TRAVIS', nil) && (RUBY_ENGINE == 'jruby')) || Gem.win_platform?
|
||||
|
||||
begin
|
||||
app = proc { |_env| [200, {}, ['Hello Server!']] }
|
||||
|
@ -78,7 +78,7 @@ RSpec.describe Capybara::Server do
|
|||
# Use a port to force a EADDRINUSE error to be generated
|
||||
server = TCPServer.new('0.0.0.0', 0)
|
||||
server_port = server.addr[1]
|
||||
d_server = instance_double('TCPServer', addr: [nil, server_port, nil, nil], close: nil)
|
||||
d_server = instance_double(TCPServer, addr: [nil, server_port, nil, nil], close: nil)
|
||||
call_count = 0
|
||||
allow(TCPServer).to receive(:new).and_wrap_original do |m, *args|
|
||||
call_count.zero? ? d_server : m.call(*args)
|
||||
|
@ -184,7 +184,7 @@ RSpec.describe Capybara::Server do
|
|||
start_request(server2, 3.0)
|
||||
server1.wait_for_pending_requests
|
||||
end.to change { done }.from(0).to(2)
|
||||
expect(server2.send(:pending_requests?)).to eq(false)
|
||||
expect(server2.send(:pending_requests?)).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -229,7 +229,7 @@ RSpec.describe Capybara::Server do
|
|||
start_request(server2, 3.0)
|
||||
server1.wait_for_pending_requests
|
||||
end.to change { done }.from(0).to(1)
|
||||
expect(server2.send(:pending_requests?)).to eq(true)
|
||||
expect(server2.send(:pending_requests?)).to be(true)
|
||||
expect do
|
||||
server2.wait_for_pending_requests
|
||||
end.to change { done }.from(1).to(2)
|
||||
|
@ -274,7 +274,7 @@ RSpec.describe Capybara::Server do
|
|||
app = -> { [200, {}, ['Hello, world']] }
|
||||
server = described_class.new(app)
|
||||
allow(Net::HTTP).to receive(:start).and_raise(SystemCallError.allocate)
|
||||
expect(server.responsive?).to eq false
|
||||
expect(server.responsive?).to be false
|
||||
end
|
||||
|
||||
[EOFError, Net::ReadTimeout].each do |err|
|
||||
|
|
|
@ -23,7 +23,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|||
it 'freshly reset session should not be touched' do
|
||||
session.instance_variable_set(:@touched, true)
|
||||
session.reset!
|
||||
expect(session.instance_variable_get(:@touched)).to eq false
|
||||
expect(session.instance_variable_get(:@touched)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -336,7 +336,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|||
it 'can attach a directory' do
|
||||
pending "Geckodriver doesn't support uploading a directory" if firefox?(session)
|
||||
pending "Selenium remote doesn't support transferring a directory" if remote?(session)
|
||||
pending "Headless Chrome doesn't support directory upload - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2521&q=directory%20upload&colspec=ID%20Status%20Pri%20Owner%20Summary" if chrome?(session) && ENV['HEADLESS']
|
||||
pending "Headless Chrome doesn't support directory upload - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2521&q=directory%20upload&colspec=ID%20Status%20Pri%20Owner%20Summary" if chrome?(session) && ENV.fetch('HEADLESS', nil)
|
||||
pending "IE doesn't support uploading a directory" if ie?(session)
|
||||
pending 'Chrome/chromedriver 73 breaks this' if chrome?(session) && chrome_gte?(73, session) && chrome_lt?(75, session)
|
||||
pending "Safari doesn't support uploading a directory" if safari?(session)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rspec/expectations'
|
||||
require 'webdrivers' if ENV['CI'] || ENV['WEBDRIVERS']
|
||||
require 'webdrivers' if ENV.fetch('CI', nil) || ENV.fetch('WEBDRIVERS', nil)
|
||||
require 'selenium_statistics'
|
||||
if ENV['TRAVIS']
|
||||
require 'coveralls'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue