B.I.
B.I.

Reputation: 706

Capybara::ExpectationNotMet, link is not appropriate

I've got Rspec/Capybara tests for my Rails 3 application.

One of the tests started to fail:

it { should have_link(I18n.t('ui.delete'), href: user_path(User.last)) } 

And this is an output error:

1) User pages index delete links as an admin user 
 Failure/Error: it { should have_link(I18n.t('ui.delete'), href: user_path(User.last)) }
 Capybara::ExpectationNotMet:
   expected to find link "o'chirish (delete)" but there were no matches. 
Also found   "o'chirish (delete)", "o'chirish (delete)",
"o'chirish (delete)", "o'chirish (delete)", "o'chirish (delete)", "o'chirish (delete)", 
"o'chirish (delete)", "o'chirish (delete)", 
which matched the selector but not all filters.
 # ./spec/requests/user_pages_spec.rb:158:in `block (5 levels) in <top (required)>'

On my web page, the links look ok (each o'chirish (delete) has a delete link)

1 admin admin [email protected] | admin  
6 author author [email protected] | author | o'chirish (delete)  
5 editorxxx editor [email protected] | editor | o'chirish (delete)  
9 home page [email protected] | o'chirish (delete)  
10 taken tekken [email protected] | o'chirish (delete)  
8 tester tester2 [email protected] | o'chirish (delete)  
7 user user [email protected] | o'chirish (delete)  

Thank you very much for any ideas!

Upvotes: 0

Views: 126

Answers (1)

cantonic
cantonic

Reputation: 1033

I saw that message in two cases as far as I remember: The link is there, but not visible (display:none;) or the href is not the same. Since you said that you can see the link you should check whether the href is set correctly.

Upvotes: 1

Related Questions