0

I am using rails 4 and capybara 2.1.0 and rspec 2.0 to develope a user registration model

here is the contents of my spec

visit register_path  
fill_in 'user[full_name]', with: "xxxx"
click_button 'Register'
expect(page).to find_link("Send hosting request")

on register form after clicking the register button i am creating a user and redirecting them to there page say user/1 on the user show template

here is the show template

  <div>
  <strong>Full Name</strong>
  <%= @user.own_profile.full_name %>
  </div>
  <%= link_to 'Send hosting request', root_path %>

but when i run the test i got error saying cannot find link

1) Register Page Create User
   Failure/Error: find_link("Send hosting request")
   Capybara::ElementNotFound:
    Unable to find link "Send hosting request"
 # ./spec/integration/register_page_spec.rb:22:in `block (2 levels) in <top (required)>'
 # -e:1:in `<main>'

i don't understand why this test is failing when i have the link on the user page

what can i do now

when i use page.has_content?('Send hosting request') it returns true

Andrei Botalov
  • 20,686
  • 11
  • 89
  • 123
Dinkaran Ilango
  • 513
  • 1
  • 4
  • 11

1 Answers1

0

Try :

expect(page).to have_link("Send hosting request")

It should work...

I found this link useful http://rubydoc.info/github/jnicklas/capybara/Capybara/RSpecMatchers

Have swing

phron
  • 1,795
  • 17
  • 23
  • Thanks for your reply when i try i got a different error as follows `Failure/Error: expect(page).to have_link('Send hosting request') expected #has_link?("Send hosting request") to return true, got false` – Dinkaran Ilango Oct 24 '13 at 06:29