O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Test with a View

Meanwhile, we still have this end-to-end test to wrap up. Let’s look at that test again:

test_first_rspec/04/gatherer/spec/features/add_project_spec.rb
 
require ​"rails_helper"
 
 
describe ​"adding projects"​ ​do
 
 
it ​"allows a user to create a project with tasks"​ ​do
 
visit new_project_path
 
fill_in ​"Name"​, with: ​"Project Runway"
 
fill_in ​"Tasks"​, with: ​"Task 1:3\nTask 2:5"
 
click_on(​"Create Project"​)
 
visit projects_path
 
expect(page).to have_content(​"Project Runway"​)
 
expect(page).to have_content(​"8"​)
 
end
 
 
end

So far we’ve gotten this test to pass up to the visit projects_path line. This line triggers a visit to the path /projects, which is routed to the index method of the ProjectController ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required