Minitest and Views
In Rails and Minitest, view testing takes place inside the controller or integration tests. Hereâs an example from the projects controller:
minitest/01/gatherer/test/controllers/projects_controller_test.rb | |
â | test â"the index method displays all projects correctly"â âdoâ |
â | on_schedule = Project.create!(due_date: 1.year.from_now, |
â | name: â"On Schedule"â, |
â | tasks: [Task.create!(completed_at: 1.day.ago, size: 1)]) |
â | behind_schedule = Project.create!(due_date: 1.day.from_now, |
â | name: â"Behind Schedule"â, |
â | tasks: [Task.create!(size: 1)]) |
â | get :index |
â | assert_select(â"#project_â#{on_schedule.id}â .on_schedule"â) |
â | assert_select(â"#project_â#{behind_schedule.id}â .behind_schedule" ... |
Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.