test/view/atom_results_test.rb
def assert_node(xml, xpath, options = {})
    result = xml.xpath(xpath, @@namespaces)

    assert result.length > 0, "Expected xpath '#{xpath}' to match in #{xml.to_s[0..200]}..."

    if options[:text]
      assert_equal options[:text], result.text.strip, "Expected #{options[:text]} as content of #{result.to_s[0..200]}"
    end

    yield result if block_given?
  end
# Instead of using assert_select, we do it ourselves with nokogiri
# for better namespace control.
#
# xml = Nokogiri::XML( rendered )
# assert_node(xml, "atom:entry") do |matched_nodes|
#   assert matched_node.first["attribute"] == "foo"
# end
Instead of using assert_select, we do it ourselves with nokogiri
for better namespace control.


Instead of using assert_select we do it ourselves with nokogiri for better namespace control .
def assert_node(xml, xpath, options = {})
    result = xml.xpath(xpath, @@namespaces)
    assert result.length > 0, "Expected xpath '#{xpath}' to match in #{xml.to_s[0..200]}..."
    if options[:text]
      assert_equal options[:text], result.text.strip, "Expected #{options[:text]} as content of #{result.to_s[0..200]}"
    end
    yield result if block_given?
  end
def assert_node ( xml , xpath , options = { } ) result = xml . xpath ( xpath , @@namespaces ) assert result . length > 0 , "Expected xpath '#{xpath}' to match in #{xml.to_s[0..200]}..." if options [ :text ] assert_equal options [ :text ] , result . text . strip , "Expected #{options[:text]} as content of #{result.to_s[0..200]}" end yield result if block_given? end
Instead of using assert_select, we do it ourselves with nokogiri
for better namespace control.
Instead of using assert_select we do it ourselves with nokogiri for better namespace control .
xml
xpath
options