Junior Track Roadmap

System testing: Capybara

This course explains what a Rails system spec is and how Capybara drives one. It covers the type: :system tag and Capybara's DSL for visiting pages, filling forms and asserting on page content. It reads the system-spec support that rspec-rails already ships in this app. It compares the rack_test driver with Selenium's JavaScript-capable variants. It then studies the sign-up password checklist, an interaction only a JavaScript-capable spec can check. It also reviews what the app's request specs prove and which client-side layer they leave untested.

What you'll learn

  • ✓What type: :system specs are and how they differ from request specs
  • ✓Capybara's DSL for visiting pages, filling forms and asserting on page content
  • ✓The system-spec support already built into rspec-rails
  • ✓The rack_test driver and why it cannot run JavaScript
  • ✓Selenium's JavaScript-capable drivers and choosing one with driven_by
  • ✓Spotting client-side behavior that only a JavaScript-capable spec can check
Free preview · Lesson 1 3 min read

What a system spec actually is

This app has dozens of request spec files under spec/requests/, with a few hundred examples between them. spec/requests/auth_spec.rb posts form params to auth_sign_up_path and checks expect(response).to redirect_to(new_auth_two_factor_setup_path). That proves the server accepted the signup and…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...