CtrlK
BlogDocsLog inGet started
Tessl Logo

rails-engine-testing

Use when creating or improving RSpec test coverage for Rails engines. Covers dummy app setup, request, routing, generator, and configuration specs for proving engine behavior within a host application.

82

1.49x
Quality

75%

Does it follow best practices?

Impact

91%

1.49x

Average score across 3 eval scenarios

SecuritybySnyk

Passed

No known issues

Optimize this skill with Tessl

npx tessl skill review --optimize ./rails-engine-testing/SKILL.md
SKILL.md
Quality
Evals
Security

Rails Engine Testing

Use this skill when the task is to create or improve test coverage for a Rails engine.

Prefer integration confidence over isolated test quantity. The main goal is to prove the engine behaves correctly inside a host app.

Quick Reference

Spec TypePurpose
RequestProves mounted endpoints work; exercises real routing and controller
RoutingVerifies engine route expectations and mount behavior
GeneratorCovers install commands, copied files, idempotency
ConfigVerifies engine respects host configuration overrides
Reload-safetyRegression tests for decorators, patches, and to_prepare hooks

HARD-GATE

EVERY engine MUST have a dummy app for testing. This ensures the engine behaves correctly within a host application environment, proving its boot and mount process.

Testing Order

  1. Identify the engine type and public behaviors.
  2. Decide which behaviors need unit tests versus dummy-app integration tests.
  3. Add the smallest integration test that proves mounting and boot work.
  4. Add request, routing, configuration, and generator coverage as needed.
  5. Add regression tests for coupling or reload bugs before refactoring.

Minimum Baseline

For a non-trivial engine, aim for:

  • one dummy-app boot or integration spec
  • one request or routing spec for mounted endpoints
  • one configuration spec for host customization
  • unit tests for public services or POROs

If generators exist, add generator specs. If decorators or reload hooks exist, add reload-focused coverage.

Common Mistakes

MistakeReality
No dummy appEngines must be tested inside a host; unit tests alone cannot prove mount and integration work
Testing against real host instead of dummyUse spec/dummy; real host apps are environment-specific and slow
Skipping reload-safety testsDecorators and patches can break in development; add regression coverage for reload behavior

Red Flags

  • Tests pass only with a specific Rails version; no version matrix or compatibility checks
  • No dummy app in spec/; engine boot and mount are untested
  • Generator specs missing when install generators exist
  • No config spec; configuration overrides are untested

What To Test In The Dummy App

Use the dummy app for:

  • mounting the engine
  • route resolution
  • controller and view rendering
  • interactions with configured host models or adapters
  • initializer-driven setup
  • copied migrations or install flow where practical

Do not rely only on isolated unit tests when the behavior depends on Rails integration.

Good Test Boundaries

  • Unit tests: services, value objects, adapters, policy objects.
  • Request specs: public engine endpoints.
  • Routing specs: engine route expectations and mount behavior.
  • System specs: only when the engine ships meaningful UI flows.
  • Generator specs: install commands, copied files, idempotency.

Review Checklist

  • Does the dummy app exercise real host integration?
  • Are engine routes tested through the engine namespace?
  • Are configurable seams covered with at least one non-default case?
  • Are generators safe to run twice?
  • Are reload-sensitive hooks protected by regression tests?

Common Gaps To Fix

  • Engine boots but no test proves the host app can mount it.
  • Request specs exist but use stubs instead of real engine wiring.
  • Configuration object exists but default and override behavior are untested.
  • Install generators exist without file or route assertions.
  • Dummy app exists only as scaffolding and is not used in meaningful specs.

Examples

Minimal dummy-app request spec (engine mounted):

# spec/requests/my_engine/root_spec.rb or spec/integration/engine_mount_spec.rb
require 'rails_helper'

RSpec.describe 'MyEngine mount', type: :request do
  it 'mounts the engine and returns success for the engine root' do
    get my_engine.root_path
    expect(response).to have_http_status(:ok)
  end
end

Configuration spec (engine respects host config):

# spec/my_engine/configuration_spec.rb
RSpec.describe MyEngine::Configuration do
  around do |example|
    original = MyEngine.config.widget_count
    MyEngine.config.widget_count = 3
    example.run
    MyEngine.config.widget_count = original
  end

  it 'uses configured value' do
    expect(MyEngine.config.widget_count).to eq(3)
  end
end

Output Style

When asked to help with tests:

  1. List the highest-value missing integration tests.
  2. Add a minimal passing baseline first.
  3. Expand with focused regression coverage for risky seams.

Integration

SkillWhen to chain
rails-engine-authorWhen structuring the engine for testability or adding configuration seams
rails-engine-reviewerWhen validating test coverage adequacy or identifying gaps
rspec-best-practicesWhen improving spec structure, matchers, or shared examples
Repository
igmarin/rails-agent-skills
Last updated
Created

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.