Pulling :content functionality up from have_selector into have_xpath
This commit is contained in:
parent
a688c28b19
commit
1625e3e9ba
|
@ -43,13 +43,7 @@ module Webrat
|
||||||
selector << "[#{key}='#{value}']"
|
selector << "[#{key}='#{value}']"
|
||||||
end
|
end
|
||||||
|
|
||||||
q = Nokogiri::CSS::Parser.parse(selector).map { |ast| ast.to_xpath }.first
|
Nokogiri::CSS::Parser.parse(selector).map { |ast| ast.to_xpath }.first
|
||||||
|
|
||||||
if options[:content]
|
|
||||||
q << "[contains(., #{xpath_escape(options[:content])})]"
|
|
||||||
end
|
|
||||||
|
|
||||||
q
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def xpath_escape(string)
|
def xpath_escape(string)
|
||||||
|
|
|
@ -55,6 +55,10 @@ module Webrat
|
||||||
@query = query
|
@query = query
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @options[:content]
|
||||||
|
query << "[contains(., #{xpath_escape(@options[:content])})]"
|
||||||
|
end
|
||||||
|
|
||||||
@document = Webrat::XML.document(stringlike)
|
@document = Webrat::XML.document(stringlike)
|
||||||
@document.xpath(*@query)
|
@document.xpath(*@query)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue