Created
February 3, 2010 15:01
-
-
Save diasjorge/293662 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Webrat | |
module Matchers | |
class HaveXpath #:nodoc: | |
def initialize(expected, options = {}, &block) | |
@expected = expected | |
@options = options | |
@handler = options.delete(:handler) | |
@block = block | |
end | |
def nokogiri_matches(stringlike) | |
if Nokogiri::XML::NodeSet === stringlike | |
@query = query.gsub(%r'^//', './/') | |
else | |
@query = query | |
end | |
add_options_conditions_to(@query) | |
@document = Webrat::XML.document(stringlike) | |
@document.xpath(@query, @handler) | |
end | |
end | |
end | |
end | |
module CustomHandler | |
class MatchHref | |
def match_href(list, expression) | |
list.find_all { |node| node['href'] =~ /#{expression}/ } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment