我有一个链接如下,我正在尝试测试(请忽略方括号):
[%= link_to "删除用户", destroy_user_account_path(@profile.user), :class => "delete", :confirm => "a", :title => "Delete #{@profile.user.name}", :method => :delete %]
下面的测试失败,但如果我注释掉 :confirm => "a" 行,它会通过:
it "should have a link to delete the user's account (using the destroy_user_account action in the registrations controller)" do get :show, :id => @profile response.should have_selector("a", :href => destroy_user_account_path(@profile.user), :confirm => "a", :title => "Delete #{@profile.user.name}", :class => "delete", :content => "Delete User") end
看我的失败:(
Failure/Error: response.should have_selector("a", expected following output to contain a <a title='Delete Michael Hartl' class='delete' href='/destroy-user-account/159' confirm='a'>Delete User</a> tag:
该行的实际 html 输出如下(同样,方括号是我的)。我注意到它在这里输出“数据确认”作为属性,而不是测试所期望的“确认”属性。
[a href="/destroy-user-account/159" class="delete" data-confirm="a" data-method="delete" rel="nofollow" title="删除 Michael Hartl"]删除用户[/一种]
谁能解释在这种情况下确认和数据确认之间有什么区别,并帮助我弄清楚为什么会出现此错误/如何解决?
谢谢!