Project

specbook

0.0
The project is in a healthy, maintained state
Specbook is a Rails engine that turns Turnip features and RSpec system specs into a browsable, animated walkthrough — screenshots with element overlays, Gherkin step cards, and Playwright trace viewer.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

Runtime

>= 7.1, < 9
 Project Readme

Specbook

Storybook for your Rails specs. Record. Replay. Review.

Specbook is a Rails engine that turns your RSpec system specs and Turnip features into a browsable, animated walkthrough — screenshots with element overlays, Gherkin step cards with syntax-highlighted Ruby source, and a Playwright trace viewer launcher.

Specbook in action

Why

Reading test output is fine for CI. But when you want to:

  • Show a designer what the new flow actually looks like
  • Onboard a new dev to the codebase by showing what the specs cover
  • Debug a flaky test by replaying the screenshot timeline
  • Review specs you didn't write yourself — whether from an AI assistant, a junior teammate, a contractor, or a forgotten corner of the suite
  • Demo to a stakeholder what's been built without spinning up the app

…you want a viewer, not a log file.

Install

# Gemfile
group :development, :test do
  gem "specbook"
end
bundle install

Mount the engine in config/routes.rb:

mount Specbook::Engine => "/specs"

Configure in config/initializers/specbook.rb:

Specbook.configure do |config|
  # Authorize who can view the player. Default: dev/test only.
  config.authorize_with = ->(controller) { controller.current_user&.admin? }

  # Optional: a "back" link in the top bar.
  config.back_link = { href: "/admin", text: "← Back to admin" }

  # Optional: VS Code link base for jumping to spec source.
  config.editor_base = "vscode://file#{Rails.root}"

  # Optional: per-actor colors for visual differentiation in the viewer.
  config.actor_colors = { "Alice" => "#3b82f6", "Bob" => "#f59e0b" }

  # Optional: directory groupings for the sidebar.
  config.ui_domains = %w[admin public mobile]
end

Add the recorder hooks to spec/rails_helper.rb:

require "specbook/rspec"

Record specs

Run your system specs with RECORD_SPECS=1 to capture screenshots:

CI=1 RECORD_SPECS=1 bundle exec rspec spec/system/

For Playwright traces:

RECORD_TRACES=1 bundle exec rspec spec/system/

Visit your mount point (e.g. /specs) to view.

Configuration

Option Type Default Purpose
authorize_with Proc dev/test only Lambda receiving the controller; return truthy to allow access
screenshot_root Pathname Rails.root.join("tmp/spec_screenshots") Where screenshots + manifest land
trace_root Pathname Rails.root.join("tmp/spec_traces") Where Playwright traces land
feature_root Pathname Rails.root Project root for resolving .feature paths in the manifest
max_runs Integer 20 Number of historical runs kept
trace_viewer_port Integer 9322 Port for Playwright trace server
actor_colors Hash {} Name → hex color for spec actors
ui_domains Array [] Top-level sidebar groupings
setup_overlay_rules Array login/exists/redirect Pattern → icon for non-screenshot steps
back_link Hash nil { href:, text: } — top-bar back link
editor_base String nil URL prefix for opening files in editor (e.g. "vscode://file/path")

Compatibility

  • Rails 7.1+
  • RSpec + Capybara
  • Turnip (optional but supported)
  • Capybara drivers: Selenium and Playwright tested

License

MIT — see LICENSE.txt.