assert_select带有命名空间和前缀的XML

时间:2015-04-01 03:44:53

标签: ruby-on-rails ruby xml ruby-on-rails-4 nokogiri

拥有如下所示的XML,我如何assert_select标记atom:link

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Title</title>
    <link>http://example.com</link>
    <description>Description</description>
    <atom:link href="http://example.com/feed" rel="self" type="application/rss+xml"/>
  </channel>
</rss>

assert_select 'title'工作正常 assert_select 'atom:link'输出Expected at least 1 element matching "atom:link", found 0..

我正在使用Rails 4.2.0

1 个答案:

答案 0 :(得分:-1)

根据Nokogiri CSS selector,您是否尝试将:替换为|

我没有测试,但它会是assert_select 'atom|link'