mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
minor code cleanup
This commit is contained in:
parent
82138ab117
commit
3f7c358564
7 changed files with 12 additions and 20 deletions
|
@ -17,7 +17,7 @@ class Capybara::RackTest::Form < Capybara::RackTest::Node
|
||||||
def size; 0; end
|
def size; 0; end
|
||||||
def read; ''; end
|
def read; ''; end
|
||||||
def append_to(_); end
|
def append_to(_); end
|
||||||
def set_encoding(_); end
|
def set_encoding(_); end # rubocop:disable Naming/AccessorMethodName
|
||||||
end
|
end
|
||||||
|
|
||||||
def params(button)
|
def params(button)
|
||||||
|
|
|
@ -101,11 +101,10 @@ module Capybara
|
||||||
private
|
private
|
||||||
|
|
||||||
def options_with_defaults(options)
|
def options_with_defaults(options)
|
||||||
expression_filters.chain(node_filters)
|
expression_filters
|
||||||
.select { |_n, filter| filter.default? }
|
.chain(node_filters)
|
||||||
.each_with_object(options.dup) do |(name, filter), opts|
|
.filter_map { |name, filter| [name, filter.default] if filter.default? }
|
||||||
opts[name] = filter.default unless opts.key?(name)
|
.to_h.merge!(options)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_filter(name, filter_class, *types, matcher: nil, **options, &block)
|
def add_filter(name, filter_class, *types, matcher: nil, **options, &block)
|
||||||
|
|
|
@ -69,11 +69,8 @@ module Capybara
|
||||||
suffixes = [[]]
|
suffixes = [[]]
|
||||||
strs.reverse_each do |str|
|
strs.reverse_each do |str|
|
||||||
if str.is_a? Set
|
if str.is_a? Set
|
||||||
prefixes = str.each_with_object([]) { |s, memo| memo.concat combine(s) }
|
prefixes = str.flat_map { |s| combine(s) }
|
||||||
|
suffixes = prefixes.product(suffixes).map { |pair| pair.flatten(1) }
|
||||||
result = []
|
|
||||||
prefixes.product(suffixes) { |pair| result << pair.flatten(1) }
|
|
||||||
suffixes = result
|
|
||||||
else
|
else
|
||||||
suffixes.each { |arr| arr.unshift str }
|
suffixes.each { |arr| arr.unshift str }
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,10 +39,8 @@ class Capybara::Selenium::Node
|
||||||
input.set_file(args)
|
input.set_file(args)
|
||||||
driver.execute_script DROP_FILE, self, input
|
driver.execute_script DROP_FILE, self, input
|
||||||
else
|
else
|
||||||
items = args.each_with_object([]) do |arg, arr|
|
items = args.flat_map do |arg|
|
||||||
arg.each_with_object(arr) do |(type, data), arr_|
|
arg.map { |(type, data)| { type: type, data: data } }
|
||||||
arr_ << { type: type, data: data }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
driver.execute_script DROP_STRING, items, self
|
driver.execute_script DROP_STRING, items, self
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,9 +37,7 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
||||||
end
|
end
|
||||||
|
|
||||||
def style(styles)
|
def style(styles)
|
||||||
styles.each_with_object({}) do |style, result|
|
styles.to_h { |style| [style, native.css_value(style)] }
|
||||||
result[style] = native.css_value(style)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
Loading…
Add table
Reference in a new issue