Junior Track Roadmap

RSpec: describe/context/it

This course covers the structure of RSpec spec files, using the specs of one Rails app. It shows how RSpec.describe names the class under test, giving examples described_class and an implicit subject, and how an added string narrows a file to one slice of behavior. It covers context as an alias of describe for shared premises, two styles of it examples, and lazy let versus eager let!. It ends with the spec/ naming convention and the app's rails_helper.rb settings.

What you'll learn

  • ✓Naming the class under test with RSpec.describe and described_class
  • ✓Grouping examples under a shared premise with context
  • ✓Writing it examples in block style and one-line matcher style
  • ✓The difference between lazy let and eager let!
  • ✓How spec/ file paths mirror app/ file paths
  • ✓The rails_helper.rb settings for FactoryBot, transactions and shoulda-matchers
Free preview · Lesson 1 3 min read

This app's payoff: RSpec, the framework it chose

That's terminal output from this app's spec suite, unedited. Every indented line traces back to a describe, context or it in one file, spec/services/identity/account_update_service_spec.rb. This course's job is to show how that file produces that output.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...