Still Curious, Still Learning

Enjoying life as it is, changing it when I can.

TDD and SOLID Design

Intention of SOLID principle is to make better code and more testable code. Here’s how.

Wishful Testing

In a shipping class example,


Now these can be wrapped by methods.

Liskoff Substitution Principle

Derived classes must be substitutable for their base classes

Contract Test

it_should_behave_like "s shipping method"
  • Dependency inversion
  • Open Closed
  • Interface Segregation


“I’m not a great programmer; I’m just a good programmer with great habits” —Kent Beck

SOLID principles help you acquire great habits. @sebasoga

Question: Any of these principles good for testing ActiveRecord models?

Answer: Only have your model info specific to database (scopes, etc). Business logic put into different classes.