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

View file

@ -46,9 +46,9 @@ Gem::Specification.new do |s|
s.add_development_dependency('rake') s.add_development_dependency('rake')
s.add_development_dependency('rspec', ['>= 3.5.0']) s.add_development_dependency('rspec', ['>= 3.5.0'])
s.add_development_dependency('rspec-instafail') 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-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('sauce_whisk')
s.add_development_dependency('selenium_statistics') s.add_development_dependency('selenium_statistics')
s.add_development_dependency('selenium-webdriver', ['~>3.5']) 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) def initialize(name, locator_type: nil, raw_locator: false, supports_exact: nil, &block)
@name = name @name = name
@filter_set = Capybara::Selector::FilterSet.add(name) {} @filter_set = Capybara::Selector::FilterSet.add(name)
@match = nil @match = nil
@label = nil @label = nil
@failure_message = nil @failure_message = nil

View file

@ -30,7 +30,7 @@ Capybara.add_selector(:button, locator_type: [String, Symbol]) do
end end
%i[value title type].inject(input_btn_xpath.union(btn_xpath).union(image_btn_xpath)) do |memo, ef| %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
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| expression_filter(:with_options) do |expr, options|
options.inject(expr) do |xpath, option| 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
end end

View file

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

View file

@ -14,7 +14,7 @@ Capybara.add_selector(:table_row, locator_type: [Array, Hash]) do
else else
initial_td = XPath.descendant(:td)[XPath.string.n.is(locator.shift)] 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)] } 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]] xpath[initial_td[tds]]
end end
end end

View file

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

View file

@ -739,7 +739,7 @@ module Capybara
# @param [Hash] options a customizable set of options # @param [Hash] options a customizable set of options
# #
def save_and_open_screenshot(path = nil, **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 end
def document def document

View file

@ -60,7 +60,7 @@ Capybara::SpecHelper.spec '#find' do
end end
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) if defined?(Process::CLOCK_MONOTONIC)
it 'will time out even if time is frozen' do it 'will time out even if time is frozen' do
@session.visit('/with_js') @session.visit('/with_js')

View file

@ -84,7 +84,7 @@ module Capybara
end end
specs.each do |spec_name, spec_options, block| 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) class_eval(&block)
end end
end end

View file

@ -840,10 +840,10 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
end end
it 'gives proper description when :visible option passed' do 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: :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: :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 end
it 'passes if there is such a table' do it 'passes if there is such a table' do