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

Rubocop 1.x was released - use it

This commit is contained in:
Thomas Walpole 2020-10-31 10:39:21 -07:00
parent b617433e2d
commit 920ce495d7
12 changed files with 28 additions and 14 deletions

View file

@ -83,6 +83,11 @@ Lint/DuplicateElsifCondition:
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
Lint/EmptyBlock:
Exclude:
- 'lib/capybara/spec/**/*'
- 'spec/**/*.rb'
Naming/PredicateName:
Exclude:
- '**/*/*matchers.rb'
@ -111,6 +116,9 @@ Style/Documentation:
- 'spec/**/*'
Enabled: false
Style/DocumentDynamicEvalDefinition:
Enabled: false
Style/DoubleNegation:
Enabled: false
@ -261,5 +269,11 @@ RSpec/PredicateMatcher:
Exclude:
- 'spec/basic_node_spec.rb'
Capybara/FeatureMethods:
RSpec/Capybara:
Enabled: false
RSpec/Capybara/FeatureMethods:
Enabled: false
RSpec/Capybara/VisibilityMatcher:
Enabled: false

View file

@ -46,9 +46,9 @@ Gem::Specification.new do |s|
s.add_development_dependency('rake')
s.add_development_dependency('rspec', ['>= 3.5.0'])
s.add_development_dependency('rspec-instafail')
s.add_development_dependency('rubocop', ['~>0.72'])
s.add_development_dependency('rubocop', ['~>1.1.0'])
s.add_development_dependency('rubocop-performance')
s.add_development_dependency('rubocop-rspec')
s.add_development_dependency('rubocop-rspec', ['~>2.0.0.pre'])
s.add_development_dependency('sauce_whisk')
s.add_development_dependency('selenium_statistics')
s.add_development_dependency('selenium-webdriver', ['~>3.5'])

View file

@ -15,7 +15,7 @@ module Capybara
def initialize(name, locator_type: nil, raw_locator: false, supports_exact: nil, &block)
@name = name
@filter_set = Capybara::Selector::FilterSet.add(name) {}
@filter_set = Capybara::Selector::FilterSet.add(name)
@match = nil
@label = nil
@failure_message = nil

View file

@ -30,7 +30,7 @@ Capybara.add_selector(:button, locator_type: [String, Symbol]) do
end
%i[value title type].inject(input_btn_xpath.union(btn_xpath).union(image_btn_xpath)) do |memo, ef|
memo[find_by_attr(ef, options[ef])]
memo.where(find_by_attr(ef, options[ef]))
end
end

View file

@ -19,7 +19,7 @@ Capybara.add_selector(:datalist_input, locator_type: [String, Symbol]) do
expression_filter(:with_options) do |expr, options|
options.inject(expr) do |xpath, option|
xpath[XPath.attr(:list) == XPath.anywhere(:datalist)[expression_for(:datalist_option, option)].attr(:id)]
xpath.where(XPath.attr(:list) == XPath.anywhere(:datalist)[expression_for(:datalist_option, option)].attr(:id))
end
end

View file

@ -33,7 +33,7 @@ Capybara.add_selector(:select, locator_type: [String, Symbol]) do
expression_filter(:with_options) do |expr, options|
options.inject(expr) do |xpath, option|
xpath[expression_for(:option, option)]
xpath.where(expression_for(:option, option))
end
end

View file

@ -14,7 +14,7 @@ Capybara.add_selector(:table_row, locator_type: [Array, Hash]) do
else
initial_td = XPath.descendant(:td)[XPath.string.n.is(locator.shift)]
tds = locator.reverse.map { |cell| XPath.following_sibling(:td)[XPath.string.n.is(cell)] }
.reduce { |xp, cell| xp[cell] }
.reduce { |xp, cell| xp.where(cell) }
xpath[initial_td[tds]]
end
end

View file

@ -12,7 +12,7 @@ module Capybara
@node_filters = {}
@expression_filters = {}
@descriptions = Hash.new { |hsh, key| hsh[key] = [] }
instance_eval(&block)
instance_eval(&block) if block
end
def node_filter(names, *types, **options, &block)

View file

@ -739,7 +739,7 @@ module Capybara
# @param [Hash] options a customizable set of options
#
def save_and_open_screenshot(path = nil, **options)
save_screenshot(path, **options).tap { |s_path| open_file(s_path) } # rubocop:disable Lint/Debugger
save_screenshot(path, **options).tap { |s_path| open_file(s_path) }
end
def document

View file

@ -60,7 +60,7 @@ Capybara::SpecHelper.spec '#find' do
end
end
context 'with frozen time', requires: [:js] do # rubocop:disable RSpec/EmptyExampleGroup
context 'with frozen time', requires: [:js] do
if defined?(Process::CLOCK_MONOTONIC)
it 'will time out even if time is frozen' do
@session.visit('/with_js')

View file

@ -84,7 +84,7 @@ module Capybara
end
specs.each do |spec_name, spec_options, block|
describe spec_name, *spec_options do # rubocop:disable RSpec/EmptyExampleGroup
describe spec_name, *spec_options do
class_eval(&block)
end
end

View file

@ -840,10 +840,10 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
end
it 'gives proper description when :visible option passed' do
expect(have_table('Lovely table', visible: true).description).to eq('have visible table "Lovely table"') # rubocop:disable Capybara/VisibilityMatcher
expect(have_table('Lovely table', visible: true).description).to eq('have visible table "Lovely table"')
expect(have_table('Lovely table', visible: :hidden).description).to eq('have non-visible table "Lovely table"')
expect(have_table('Lovely table', visible: :all).description).to eq('have table "Lovely table"')
expect(have_table('Lovely table', visible: false).description).to eq('have table "Lovely table"') # rubocop:disable Capybara/VisibilityMatcher
expect(have_table('Lovely table', visible: false).description).to eq('have table "Lovely table"')
end
it 'passes if there is such a table' do