---
title: Write comprehensive tests
impact: CRITICAL
impactDescription: Ensure code quality and prevent regressions.
tags: ruby, quality, testing, stability
---

## Write comprehensive tests

Ensure code quality and prevent regressions. Write unit tests for models/services, integration tests for controllers, and system tests for critical paths. Aim for >80% coverage for business-critical code.

**Incorrect:**

```ruby
# No tests covering edge cases or failure modes
```

**Correct:**

```ruby
RSpec.describe User, type: :model do
  it "is valid with proper attributes" do
    # ...
  end
  
  it "is invalid without an email" do
    # ...
  end
end
```

**Tools:** RSpec, Minitest, SimpleCov
