Skip to content

rails-cto-minitest

The testing skill. Writes and maintains Minitest tests using the Spec DSL.

What it does

This project uses Minitest::Spec DSL — not RSpec, not vanilla Minitest::Test. Every test file follows a consistent structure so tests are easy to scan and extend. The skill covers:

  • Model tests in test/models/
  • Command and service tests in test/commands/ and test/services/
  • Controller and integration tests in test/controllers/ and test/integration/
  • Job tests in test/jobs/
  • ViewComponent tests in test/components/
  • System tests in test/system/

Core conventions the skill enforces:

  • subject block declared exactly once at the top of the class
  • let(:attributes) pattern for test variations — don't reassign subject inline
  • describe blocks for contextual grouping
  • Parallel tests enabled (the test helper is already patched)
  • SimpleCov coverage reported via the JSON formatter so rails-cto-qa can read it
  • Fabricators (Fabrication gem) for test data, not fixtures

When it triggers

  • Creating or fixing any file under test/
  • Generating a new model, controller, command, job, or component that needs accompanying tests
  • When you mention test, minitest, spec, coverage, fixture, fabricator, assertion, or ask to "add tests"
  • Whenever rails-cto-qa detects a changed .rb file without a matching test

Example

ruby
# test/models/plan_test.rb
require "test_helper"

class PlanTest < ActiveSupport::TestCase
  let(:attributes) { {} }

  subject { Fabricate.build(:plan, **attributes) }

  describe "#price_summary" do
    describe "with monthly interval" do
      let(:attributes) { { amount: 1200, interval: "month" } }

      it "returns formatted price" do
        assert_equal "$12.00 / month", subject.price_summary
      end
    end

    describe "with annual interval" do
      let(:attributes) { { amount: 12000, interval: "year" } }

      it "returns formatted price" do
        assert_equal "$120.00 / year", subject.price_summary
      end
    end
  end
end

View source

skills/rails-cto-minitest/SKILL.md on GitHub →

Released under the MIT License.