我需要找到外部电子邮件中存在天气不关注链接,并且它不应该出现在任何内部电子邮件中。
test "should have nofollow in external links and not in internal links in comment" do
visit @game_path
fill_in('comment_comment', :with => 'Please click link <a href='http://www.internallink.com/soccer'> internal link <a/> and click external link <a href='http://www.google.com'> external link <a/>
click_button('submit_comment')
assert page.has_no_css?('div.error'), "Error div found on page after posting comment"
assert page.has_content?('Please click link '), "Comment not found on page after posting"
ext = find(:xpath, "//a[@href='http://www.google.com']")
assert_equal(ext['rel'], "nofollow")
internal = find(:xpath, "//a[@href='http://www.internallink.com/soccer']")
assert_equal(internal.try(:rel), nil)
end
它在assert_equal(int.try(:rel), nil)
. 有朋友可以指导我解决吗?
我的最终目标是在用户评论中进行测试,外部链接是否应该有 rel='nofollow' 属性?