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
|
@ -84,7 +84,7 @@ module Capybara
|
|||
def warn(message, uplevel: 1)
|
||||
Kernel.warn(message, uplevel: uplevel)
|
||||
end
|
||||
|
||||
|
||||
if defined?(Process::CLOCK_MONOTONIC_RAW)
|
||||
def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC_RAW; end
|
||||
elsif defined?(Process::CLOCK_MONOTONIC_PRECISE)
|
||||
|
|
|
@ -17,7 +17,7 @@ class Capybara::RackTest::Form < Capybara::RackTest::Node
|
|||
def size; 0; end
|
||||
def read; ''; end
|
||||
def append_to(_); end
|
||||
def set_encoding(_); end
|
||||
def set_encoding(_); end # rubocop:disable Naming/AccessorMethodName
|
||||
end
|
||||
|
||||
def params(button)
|
||||
|
|
|
@ -101,11 +101,10 @@ module Capybara
|
|||
private
|
||||
|
||||
def options_with_defaults(options)
|
||||
expression_filters.chain(node_filters)
|
||||
.select { |_n, filter| filter.default? }
|
||||
.each_with_object(options.dup) do |(name, filter), opts|
|
||||
opts[name] = filter.default unless opts.key?(name)
|
||||
end
|
||||
expression_filters
|
||||
.chain(node_filters)
|
||||
.filter_map { |name, filter| [name, filter.default] if filter.default? }
|
||||
.to_h.merge!(options)
|
||||
end
|
||||
|
||||
def add_filter(name, filter_class, *types, matcher: nil, **options, &block)
|
||||
|
|
|
@ -69,11 +69,8 @@ module Capybara
|
|||
suffixes = [[]]
|
||||
strs.reverse_each do |str|
|
||||
if str.is_a? Set
|
||||
prefixes = str.each_with_object([]) { |s, memo| memo.concat combine(s) }
|
||||
|
||||
result = []
|
||||
prefixes.product(suffixes) { |pair| result << pair.flatten(1) }
|
||||
suffixes = result
|
||||
prefixes = str.flat_map { |s| combine(s) }
|
||||
suffixes = prefixes.product(suffixes).map { |pair| pair.flatten(1) }
|
||||
else
|
||||
suffixes.each { |arr| arr.unshift str }
|
||||
end
|
||||
|
|
|
@ -39,10 +39,8 @@ class Capybara::Selenium::Node
|
|||
input.set_file(args)
|
||||
driver.execute_script DROP_FILE, self, input
|
||||
else
|
||||
items = args.each_with_object([]) do |arg, arr|
|
||||
arg.each_with_object(arr) do |(type, data), arr_|
|
||||
arr_ << { type: type, data: data }
|
||||
end
|
||||
items = args.flat_map do |arg|
|
||||
arg.map { |(type, data)| { type: type, data: data } }
|
||||
end
|
||||
driver.execute_script DROP_STRING, items, self
|
||||
end
|
||||
|
|
|
@ -37,9 +37,7 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
|||
end
|
||||
|
||||
def style(styles)
|
||||
styles.each_with_object({}) do |style, result|
|
||||
result[style] = native.css_value(style)
|
||||
end
|
||||
styles.to_h { |style| [style, native.css_value(style)] }
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -528,7 +528,7 @@ Capybara::SpecHelper.spec '#find' do
|
|||
expect(@session.find(:link, 'test-foo')[:id]).to eq 'foo'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'should warn if passed count options' do
|
||||
allow(Capybara::Helpers).to receive(:warn)
|
||||
@session.find('//h1', count: 44)
|
||||
|
|
Loading…
Reference in a new issue