lundi 3 avril 2017

Using a rails model in Capybara tests

Okay, so I have set up a project where all I have to do is display a set of records from an SQLlite3 database. I have a table in that database, and I want the root page to display all the records in the database. I have this working, but now I want to set up a Capybara test to make sure that the page has the first and last record from the table on the page. My thinking was along the lines of:

require 'rails_helper'
describe "seeing record from scotlands model " do
  specify "I can see a list of all charities" do
    visit "/"
    expect(page).to have_content "@table.first_record"
  end
end

However, this provides no link to the model so I cannot access it, understandably. How do I get a link to the table from the test file? Any help is much appreciated.

Aucun commentaire:

Enregistrer un commentaire