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.
Rails ships with Minitest. Most real-world projects use RSpec instead.
| Test type | Scope | Tool |
|---|---|---|
| Unit (model) | Tests 1 model, no browser | type: :model (RSpec) / ActiveSupport::TestCase |
| Controller/Request | Tests actions, params, response codes | type: :request (RSpec) |
| Integration | Multiple layers, real DB, no browser | ActionDispatch::IntegrationTest |
| System | Full browser (JS), Capybara + Selenium | ApplicationSystemTestCase |
Run tests: bundle exec rspec or rails test.