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}']"
|
||||
end
|
||||
|
||||
q = Nokogiri::CSS::Parser.parse(selector).map { |ast| ast.to_xpath }.first
|
||||
|
||||
if options[:content]
|
||||
q << "[contains(., #{xpath_escape(options[:content])})]"
|
||||
end
|
||||
|
||||
q
|
||||
Nokogiri::CSS::Parser.parse(selector).map { |ast| ast.to_xpath }.first
|
||||
end
|
||||
|
||||
def xpath_escape(string)
|
||||
|
|
|
@ -55,6 +55,10 @@ module Webrat
|
|||
@query = query
|
||||
end
|
||||
|
||||
if @options[:content]
|
||||
query << "[contains(., #{xpath_escape(@options[:content])})]"
|
||||
end
|
||||
|
||||
@document = Webrat::XML.document(stringlike)
|
||||
@document.xpath(*@query)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue