DRY in builders
This commit is contained in:
parent
8648cbf75b
commit
f72cca9543
|
@ -35,8 +35,7 @@ module Capybara
|
|||
when XPath::Expression
|
||||
raise ArgumentError, 'XPath expressions are not supported for the :class filter with CSS based selectors'
|
||||
when Regexp
|
||||
strs = Selector::RegexpDisassembler.new(classes).substrings
|
||||
strs.map { |str| "[class*='#{str}'#{' i' if classes.casefold?}]" }.join
|
||||
attribute_conditions(class: classes)
|
||||
else
|
||||
cls = Array(classes).group_by { |cl| cl.start_with? '!' }
|
||||
(cls[false].to_a.map { |cl| ".#{Capybara::Selector::CSS.escape(cl)}" } +
|
||||
|
|
|
@ -26,10 +26,8 @@ module Capybara
|
|||
|
||||
def class_conditions(classes)
|
||||
case classes
|
||||
when XPath::Expression
|
||||
XPath.attr(:class)[classes]
|
||||
when Regexp
|
||||
XPath.attr(:class)[regexp_to_xpath_conditions(classes)]
|
||||
when XPath::Expression, Regexp
|
||||
attribute_conditions(class: classes)
|
||||
else
|
||||
Array(classes).map do |klass|
|
||||
if klass.start_with?('!')
|
||||
|
|
Loading…
Reference in New Issue