Rails tích hợp sẵn Minitest. Hầu hết project thực tế dùng RSpec thay thế.
| Loại test | Phạm vi | Tool |
|---|---|---|
| Unit (model) | Test 1 model, không browser | type: :model (RSpec) / ActiveSupport::TestCase |
| Controller/Request | Test action, params, response code | type: :request (RSpec) |
| Integration | Test nhiều layer, DB thật, không browser | ActionDispatch::IntegrationTest |
| System | Full browser (JS), Capybara + Selenium | ApplicationSystemTestCase |
Chạy test: bundle exec rspec hoặc rails test.