Skipping actions

You can configure Reflekt to skip “no undo” methods like deletion and sending email:

class ExampleClass
  reflekt_skip :method_name

Databases

Use can use the same reflekt_skip technique on the method that saves to the database to avoid persisting test data. If you still want to test saving data to the database then use dependency injection to connect to a dummy database.

Rendering to the UI

Use reflekt_skip on methods that do the final render to the UI to avoid a visual mess of duplicated elements. Separate the final output from the rendering logic so that Reflekt can track changes in output.

Don’t do:

def show(product)
  # Business logic.
  product.title = "Showing #{product.name}"

  # Rendering logic.
  puts product
end

Do:

reflekt_skip :render

# Business logic.
def show(product)
  product.title = "Showing #{product.name}"  
  render(product)
end

# Rendering logic.
def render(product)
  puts product
end