テストしようとしている次のようなリンクがあります(角括弧は無視してください):
[%= link_to "ユーザーの削除", destroy_user_account_path(@profile.user), :class => "delete", :confirm => "a", :title => "削除 #{@profile.user.name}", :メソッド => :削除 %]
以下のテストは失敗しますが、 :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 の削除"]ユーザーの削除[/ a]
このコンテキストで確認とデータ確認の違いを説明し、このエラーが発生する理由/修正方法を理解するのに役立つ人はいますか?
ありがとう!