Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Teamcapybara Capybara Feature Spec DSL

From Leeroopedia
Knowledge Sources
Domains Testing, DSL
Last Updated 2026-02-12 00:00 GMT

Overview

A domain-specific language pattern that provides human-readable aliases for test structure methods to express acceptance tests in business terms.

Description

Feature Spec DSL wraps RSpec's standard structure methods (describe, it, before, let) with aliases that read naturally as acceptance test specifications:

  • featureRSpec.describe (with type: :feature)
  • scenarioit
  • backgroundbefore
  • given / given!let / let!

Additionally, Capybara::DSL provides a page method returning the current Capybara::Session, and delegates all Session DSL methods (visit, find, fill_in, click_on, etc.) to it.

Usage

Use this DSL when writing feature or system specs that describe user-facing workflows. The aliases make tests read like plain English scenarios.

Theoretical Basis

The DSL follows the Facade pattern — it creates a thin layer of readable aliases over existing RSpec and Capybara APIs:

# Abstract pattern (not actual code)
feature = describe(type: :feature)
scenario = it
background = before
given = let
page = Capybara.current_session

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment