Junior Track Roadmap

Testing culture: RGR cycle

This course teaches the Red-Green-Refactor discipline using one service and one spec from this app: Identity::AccountUpdateService and its RSpec file. It follows commit 999182a, which fixed a bug where a rejected password change could still commit a name change. The lessons trace the regression test as Red against the old code, then as Green against the fix. They also explain why a test that never failed proves nothing, how to refactor only under a green suite, and why the cycle repeats as a loop.

What you'll learn

  • ✓The three states of Red-Green-Refactor and their fixed order
  • ✓Why a test that never failed proves nothing about the bug it guards against
  • ✓Making the smallest change that turns a red test green
  • ✓How a transaction rolls back on a raised exception but commits on a false return
  • ✓Refactoring only while the suite is green, without changing behavior
  • ✓Reading negative and positive examples as one complete cycle
Free preview · Lesson 1 3 min read

Red-green-refactor: the discipline, and the spec behind this course

That's the spec file this course follows, run for this course. Gemfile line 60 says gem "rspec-rails": this app is tested with RSpec, not Minitest. The discipline this course teaches works the same in either framework, and every example comes from this app's own code.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...