Rspec link_to - including the data confirmation / confirmation attribute, leads to a test failure

I have a link as follows: I'm trying to check (please ignore the square brackets):

[% = link_to "Delete user", destroy_user_account_path (@ profile.user) ,: class => "delete" ,: confirm => "a",: title => "Delete #{@profile.user.name}", : method =>: delete%]

Below is the test, but if I comment on the line: confirm => "a", it passes:

  it "should have a link to delete the user 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

Here is my failure: (

 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:

The actual html output for this line is as follows (again, the square brackets are mine). I note that "data confirmation" is displayed here as an attribute, not the "confirm" that the test expects.

[a href= "/destroy-user-account/159" class= "" data-confirm = "a" data-method = "delete" rel= "nofollow" title= " Hartl" ] [/a]

- , , , / ?

!

+3
2

"" HTML. data-whatever - HTML5, , Javascript .

: <a confirm="foo"></a> HTML, <a data-confirm="foo"></a> .

Rails UJS data-confirm , , . data-confirm.

, :

response.should have_selector("a",
                              :href => destroy_user_account_path(@profile.user),
                              'data-confirm' => "a",
                              :title => "Delete #{@profile.user.name}",
                              :class => "delete", 
                              :content => "Delete User")

, , .

+1

"" - " ", link_to.

link_to anything, :confirm => "Message" # is equivalent to
link_to anything, 'data-confirm' => "Message"

, " ":

response.should have_selector("a",
                              :href => destroy_user_account_path(@profile.user),
                              'data-confirm' => "a",
                              :title => "Delete #{@profile.user.name}",
                              :class => "delete", 
                              :content => "Delete User")
+1

All Articles