Skip to main content
skill CX Codex

capybara-skill — Claude Code skill: Ruby E2E tests with RSpec

Generates acceptance tests for web apps using Capybara and RSpec. Use it to automate clicks, form fills, and page assertions in Ruby-based E2E suites.

MIT 210 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill capybara-skill -a claude-code
Open on GitHub

What capybara-skill does

This skill accelerates E2E test creation with Capybara DSL patterns. It covers navigation (visit, go_back), user interactions (fill_in, click_button, select), element location (CSS, XPath, data attributes), and RSpec matchers for page state (have_content, have_current_path). Tests organize around feature specs and support scoped assertions through within blocks.

The skill includes setup for local test runs via bundle exec rspec spec/features/ and cloud execution through TestMu AI's LambdaTest integration. You'll need a Ruby project with capybara and selenium-webdriver in the Gemfile.

What it helps with

  • write an acceptance test for a login flow with redirect verification
  • assert that a form displays an error for invalid input
  • locate an element by data attribute and click it
  • run tests in a remote browser on LambdaTest
  • scope test interactions to a single component with within

Example prompts for the agent

  • Generate an E2E test that visits /login, fills email and password, and clicks Login
  • Write an assertion to check that the page contains Dashboard after a button click
  • Create a test that finds an element by selector and verifies its content

How to install capybara-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill capybara-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/capybara-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/capybara-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about capybara-skill

How do I install capybara-skill in Claude Code?

Run npx skills add LambdaTest/agent-skills --skill capybara-skill -a claude-code, then open ~/.claude/skills/capybara-skill/SKILL.md.

What does capybara-skill do?

It generates acceptance tests for web applications using Capybara DSL and RSpec. Provides patterns for navigation, form interaction, element selection, and page state verification.

What dependencies do I need?

A Ruby project with capybara and selenium-webdriver gems in the Gemfile. For cloud tests, provide TestMu AI credentials (LT_USERNAME and LT_ACCESS_KEY).

Source text

SKILL.md · MIT
---
name: capybara-skill
description: >
  Generates Capybara E2E tests in Ruby with RSpec integration. Acceptance
  testing DSL for web apps. Use when user mentions "Capybara", "visit",
  "fill_in", "click_button", "Ruby E2E". Triggers on: "Capybara",
  "Ruby acceptance test", "fill_in", "click_button", "have_content".
languages:
  - Ruby
category: e2e-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# Capybara Automation Skill

## Core Patterns

### Basic Test (RSpec)

```ruby
require 'capybara/rspec'

RSpec.describe 'Login', type: :feature do
  it 'logs in with valid credentials' do
    visit '/login'
    fill_in 'Email', with: '[email protected]'
    fill_in 'Password', with: 'password123'
    click_button 'Login'
    expect(page).to have_content('Dashboard')
    expect(page).to have_current_path('/dashboard')
  end

  it 'shows error for invalid credentials' do
    visit '/login'
    fill_in 'Email', with: '[email protected]'
    fill_in 'Password', with: 'wrong'
    click_button 'Login'
    expect(page).to have_content('Invalid credentials')
  end
end
```

### DSL

```ruby
# Navigation
visit '/path'
go_back
go_forward

# Interacting
fill_in 'Label or Name', with: 'text'
choose 'Radio Label'
check 'Checkbox Label'
uncheck 'Checkbox Label'
select 'Option', from: 'Select Label'
attach_file 'Upload', '/path/to/file'
click_button 'Submit'
click_link 'More Info'
click_on 'Button or Link'

# Finding
find('#id')
find('.class')
find('[data-testid="x"]')
find(:xpath, '//div')
all('.items').count

# Matchers
expect(page).to have_content('text')
expect(page).to have_selector('#element')
expect(page).to have_css('.class')
expect(page).to have_button('Submit')
expect(page).to have_field('Email')
expect(page).to have_link('Click Here')
expect(page).to have_current_path('/expected')
expect(page).to have_no_content('error')
```

### Within Scope

```ruby
within('#login-form') do
  fill_in 'Email', with: '[email protected]'
  click_button 'Login'
end

within_table('users') do
  expect(page).to have_content('Alice')
end
```

### TestMu AI Cloud

```ruby
Capybara.register_driver :lambdatest do |app|
  caps = Selenium::WebDriver::Remote::Capabilities.new(
    browserName: 'chrome',
    'LT:Options' => {
      user: ENV['LT_USERNAME'], accessKey: ENV['LT_ACCESS_KEY'],
      build: 'Capybara Build', name: 'Login Test',
      platform: 'Windows 11', video: true
    }
  )
  Capybara::Selenium::Driver.new(app,
    browser: :remote,
    url: 'https://hub.lambdatest.com/wd/hub',
    capabilities: caps)
end
Capybara.default_driver = :lambdatest
```

## Setup: `gem 'capybara'` + `gem 'selenium-webdriver'` in Gemfile
## Run: `bundle exec rspec spec/features/`

## Cloud (TestMu AI)

For remote browser execution, see [reference/cloud-integration.md](reference/cloud-integration.md) and [shared/testmu-cloud-reference.md](../shared/testmu-cloud-reference.md).

## Deep Patterns

See `reference/playbook.md` for production-grade patterns:

| Section | What You Get |
|---------|-------------|
| §1 Project Setup | Gemfile, Capybara config, driver registration, LambdaTest |
| §2 Feature Specs | Login flows, JavaScript interactions, modals, async content |
| §3 Page Objects | SitePrism pages with elements/sections, usage in specs |
| §4 API Testing | Request specs with auth headers, JSON assertions |
| §5 Database Cleaning | DatabaseCleaner transaction/truncation strategies |
| §6 Matchers & Helpers | Custom helpers, sign_in, expect_flash |
| §7 CI/CD Integration | GitHub Actions with Postgres, Redis, Chrome |
| §8 Debugging Table | 12 common problems with causes and fixes |
| §9 Best Practices | 14-item Capybara testing checklist |

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →

Project sponsors

Companies that keep this analytics open