Junior Track Roadmap

Integration testing: requests

This course covers request specs in a Rails app, drawing on the app's own spec/requests/ files. It explains what type: :request sets up and how get, post, patch and delete send a request through the router, middleware and controller without a browser. It covers response assertions with have_http_status, response.body and response.status. It also compares request specs with system specs and controller specs. Later lessons cover a reusable sign_in helper, CRUD and JSON examples, and tests for access control and failure paths.

What you'll learn

  • ✓What the type: :request tag sets up and which HTTP verb helpers this app uses
  • ✓Checking responses with have_http_status, response.body and response.status
  • ✓How request specs differ from system specs and controller specs
  • ✓A reusable sign_in helper scoped to request specs with config.include
  • ✓Asserting database changes in CRUD specs and parsed JSON in API specs
  • ✓Testing access control, required login and validation failures
Free preview · Lesson 1 3 min read

What a request spec actually is

The course right before this one, System testing: Capybara, spent seven lessons on type: :system: a browser, JavaScript and Capybara's DSL. It closed by naming the layer underneath: this app's spec/requests/, dozens of files and a few hundred examples that already prove server-side correctness…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...