Have a look at our new "Complete Guide to Optimizing Slow Tests"! Discover →

Diamond Kata – TDD with only Property-Based Tests

The Diamond Kata is a simple exercise that Seb Rose described in a blog post on recycling tests in TDD. Seb describes the Diamond Kata as: Given a letter, print a diamond starting with ‘A’ with the supplied letter at the widest point. For example: print-diamond ‘C’ prints A B B C C B B […]

Writing One-Liner RSpec Tests in Rails with Shoulda-Matchers

Introduction Shoulda Matchers provides Test::Unit and RSpec-compatible one-liners that test common Rails functionality. It helps you write tests that would otherwise be much longer, more complex, and error-prone. Using shoulda-matchers for testing simplifies the entire process. Let’s take a look at shoulda-matchers in action, compared to its RSpec-only equivalent. One-Liner ActiveModel Tests Below is an […]