Rails Testing Exercises

So you want to get started with Ruby testing. All the cool kids are doing it. Seriously though, testing is fundamental. In this course of tutorials you’ll learn methods for improving code quality and minimizing time required to add new features to software by ensuring that each facet of the program works as expected.

This course is for beginners with some Ruby skills. It doesn’t assume any testing experience and starts with passing your very first test, but once you’ve finished, take a look at the Test Driven Development page and see how tests can help you write great code right from the start of a new project.


Passing Your First Test

In order to get your feet wet with testing, let's write a test for a simple Ruby class.

Testing ActiveRecord

In this exercise, you'll write an RSpec model test to verify a simple validation.

Write an Integration Test

In this example, we'll be using Capybara to write an integration test.

Write a controller spec

In this example, you'll write a unit test to make sure the create action for PeopleController works as expected based on the return value of save.

Write A Feature With Tests

Time to put it all together! In this exercise, you'll add enhance a small Rails applications by adding the ability edit existing people. You'll implement the necessary actions and views in the Rails application, writing tests as you go.