Destroy All Software Screencast Reviews

Fast Tests With and Without Rails Episode Review

The specs in the final solution abuses mock by mocking the ActiveRecord API. The expectation mocks update_attributes. He says the solution only depends on RSpec and specs run outside of Rails, so the specs run fast. The problem is that the dependency on Rails exists because of the coupling created by the mocking of ActiveRecord. The tests are now brittle and can break when you upgrade Rails if the active record API changes.


alice.should_receive(:update_attributes).with(happiness => 60)

This ties the test to implementation. Here is a better way:


expect do
  alice.nice_walk increase(:happiness).by(60)

This simplifies outcomes and does not break when implementation of ActiveRecord changes (for instance, when you upgrade the Rails framework).

Growing a Test Suite Episode Review

This is the review of the solution discussed in Growing a Test Suite screencast. Here is a list of things that the solution violates:

  1. Separate Command from Query. digest() method is a command. digest() method should not return any value
  2. Allocate responsibilities to the right class. digest() method does not belong to the Cheese class. Semantically it does not make any sense. Only a living organism can digest food.
  3. Law of Demeter.

Here is my solution:

class Walrus
  attr_reader :energy

  def initialize
    @energy = 0

  def eat(food)
    @energy +=


  def digest
    p 'Digesting happens inside my body...'

class Cheese
  def energy

cheese =
w  =

p "Energy before eating is : #{}"

p "Energy now is : #{}" 

Related Articles

Create your own user feedback survey