1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Rubocop update

This commit is contained in:
Thomas Walpole 2020-07-13 23:23:08 -07:00
parent 8009413ed1
commit 50125e25f6
4 changed files with 30 additions and 13 deletions

View file

@ -73,6 +73,9 @@ Lint/DeprecatedOpenSSLConstant:
Lint/MixedRegexpCaptureTypes:
Enabled: true
Lint/DuplicateElsifCondition:
Enabled: true
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
@ -159,6 +162,21 @@ Style/BisectedAttrAccessor:
Style/RedundantAssignment:
Enabled: true
Style/ArrayCoercion:
Enabled: true
Style/CaseLikeIf:
Enabled: true
Style/HashAsLastArrayItem:
Enabled: true
Style/HashLikeCase:
Enabled: true
Style/RedundantFileExtensionInRequire:
Enabled: true
Layout/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true

View file

@ -484,7 +484,7 @@ module Capybara
require 'capybara/rack_test/node'
require 'capybara/rack_test/form'
require 'capybara/rack_test/browser'
require 'capybara/rack_test/css_handlers.rb'
require 'capybara/rack_test/css_handlers'
require 'capybara/selenium/node'
require 'capybara/selenium/driver'

View file

@ -239,13 +239,14 @@ module Capybara
hints[:styles] = options[:style] if use_default_style_filter?
hints[:position] = true if use_spatial_filter?
if selector_format == :css
case selector_format
when :css
if node.method(:find_css).arity != 1
node.find_css(css, **hints)
else
node.find_css(css)
end
elsif selector_format == :xpath
when :xpath
if node.method(:find_xpath).arity != 1
node.find_xpath(xpath(exact), **hints)
else

View file

@ -45,20 +45,18 @@ module Capybara
JS
end
SCROLL_POSITIONS = {
top: '0',
bottom: 'arguments[0].scrollHeight',
center: '(arguments[0].scrollHeight - arguments[0].clientHeight)/2'
}.freeze
def scroll_to_location(location)
scroll_y = case location
when :top
'0'
when :bottom
'arguments[0].scrollHeight'
when :center
'(arguments[0].scrollHeight - arguments[0].clientHeight)/2'
end
driver.execute_script <<~JS, self
if (arguments[0].scrollTo){
arguments[0].scrollTo(0, #{scroll_y});
arguments[0].scrollTo(0, #{SCROLL_POSITIONS[location]});
} else {
arguments[0].scrollTop = #{scroll_y};
arguments[0].scrollTop = #{SCROLL_POSITIONS[location]};
}
JS
end