rezzz
rezzz

Reputation: 71

RSpec and Capybara setup, have_no_content doesn't seem to be working

I'm creating an app where I have a simple delete record on the index of the records once a user logs in. When I don't have the user logging in under my rspec specs, the delete works. Meaning that the has_no_content test returns true. But once I put in place the authentication required to access the index of records, the test fails. Any thoughts?

before do
  @records = Factory(:record)
  login_user
end

it "should delete a record" do
  visit records_path
  find("#record_#{@records.id}").click_link 'Delete'

  page.should have_content "Record has been deleted"
  page.should have_no_content "Record 1"
end 

Upvotes: 2

Views: 1245

Answers (1)

rezzz
rezzz

Reputation: 71

Nevermind - I figured it out with the help of using launchy.

My initial thought was that I was some how losing the "session" and that once the delete link was clicked, then the login page was being displayed again. That wasn't the case at all. I did notice though that the header of my app also contained "Record 1" in it. Therefore the spec would fail for obvious reasons. Head to desk - sorry about that, but I figured I'd post my own stupidity and looking way deeper than I needed to.

Upvotes: 2

Related Questions