Yehuda Katz wrote:
> Any ideas?
Use assert_select to select the node around the target node you need.
Then do this:
assert_select ''some node'' do |node|
assert_xml node.to_s
assert_xpath ''match_me[ . = "contents" ]''
end
Problem: XPath can''t do RegExps (last time I checked). But it can do
any other kind of query you can think of, competitive with query
systems like SQL SELECT.
The assert_xpath support code is below my sig.
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!
require ''rexml/document''
include REXML
module AssertXPath
def assert_xml(contents)
contents.gsub!(''\\\'''',
''''')
@xdoc = Document.new(contents)
end
def assert_xpath(path, message = '''')
former = @xdoc
@xdoc = XPath.first(@xdoc, path)
assert_not_nil @xdoc, message +
"\nseeking: #{path.inspect} in\n#{former.to_s}"
yield(@xdoc) if block_given?
ensure
@xdoc = former
end
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---