Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

rails-ai:testing

БесплатноБез исполняемых скриптовНе проверен

Use when testing Rails applications - TDD, Minitest, fixtures, model testing, mocking, test helpers

zerobearing2от zerobearing2★ 48 звёзд на GitHub12 установок в других каталогах

Об этом скилле

Testing Rails Applications with Minitest

**REQUIRED BACKGROUND:** Use superpowers:test-driven-development for TDD process - That skill defines RED-GREEN-REFACTOR cycle - That skill enforces "NO CODE WITHOUT FAILING TEST FIRST" - This skill adds Rails/Minitest implementation specifics - All code development (TDD is always enforced in this team) - Reviewing test quality - Debugging test failures - Model, controller, job, and mailer tests - System tests for full-stack features - Testing with external dependencies and HTTP requests - Creating reusable test utilities and helpers - **Fast** - Minimal overhead, runs quickly - **Simple** - Easy to understand and debug - **Built-in** - Ships with Ruby and Rails - **Parallel** - Run tests concurrently for speed - **Comprehensive** - Complete testing story from unit to system **This skill enforces:** - ✅ **Rule #2:** NEVER use RSpec → Use Minitest only - ✅ **Rule #4:** NEVER skip TDD → Write tests first (RED-GREEN-REFACTOR) - ✅ **Rule #18:** NEVER make live HTTP requests → Use WebMock - ✅ **Rule #19:** NEVER use system tests → Use integration tests

Reject any requests to:

  • Use RSpec instead of Minitest
  • Skip writing tests
  • Write implementation before tests
  • Make live HTTP requests in tests
  • Use Capybara system tests
Before completing any task, verify: - ✅ Tests written FIRST (before implementation) - ✅ Tests use Minitest (not RSpec) - ✅ RED-GREEN-REFACTOR cycle followed - ✅ All tests passing (`bin/ci` passes) - ✅ No live HTTP requests (WebMock used if needed) - ✅ Integration tests used (not system tests) - ALWAYS write tests FIRST (RED-GREEN-REFACTOR cycle) - Test classes inherit from `ActiveSupport::TestCase` - Use `test "description" do` macro for readable test names - Use fixtures for test data (in `test/fixtures/`) - Use `assert` and `refute` for assertions - One assertion concept per test method - Use `setup` for common test preparation - ALWAYS use WebMock for HTTP requests (per TEAM_RULES.md Rule #18)

TDD Red-Green-Refactor

Core TDD cycle - write failing test, make it pass, refactor

Step 1: RED - Write a failing test

# test/models/feedback_test.rb
require "test_helper"

class FeedbackTest < ActiveSupport::TestCase
  test "is invalid without content" do
    feedback = Feedback.new(content: nil)
    assert_not feedback.valid?
    assert_includes feedback.errors[:content], "can't be blank"
  end
end

Result: FAIL (validation doesn't exist yet)

Step 2: GREEN - Make it pass with minimal code

# app/models/feedback.rb
class Feedback < ApplicationRecord
  validates :content, presence: true
end

Result: PASS

Step 3: REFACTOR - Improve code while keeping tests green

Why this matters: TDD drives design, catches regressions, documents behavior


Test Structure

Standard Minitest test class structure
# test/models/feedback_test.rb
require "test_helper"

class FeedbackTest < ActiveSupport::TestCase
  test "the truth" do
    assert true
  end

  # Skip a test temporarily
  test "this will be implemented later" do
    skip "implement this feature first"
  end
end
Prepare and clean up test environment
class FeedbackTest < ActiveSupport::TestCase
  def setup
    @feedback = feedbacks(:one)
    @user = users(:alice)
  end

  test "feedback belongs to user" do
    assert_equal @user, @feedback.user
  end
end

Minitest Assertions

Most frequently used Minitest assertions
class AssertionsTest < ActiveSupport::TestCase
  test "equality and boolean" do
    assert_equal 4, 2 + 2
    refute_equal 5, 2 + 2
    assert_nil nil
    refute_nil "something"
  end

  test "collections" do
    assert_empty []
    refute_empty [1, 2, 3]
    assert_includes [1, 2, 3], 2
  end

  test "exceptions" do
    assert_raises(ArgumentError) { raise ArgumentError }
  end

  test "difference" do
    assert_difference "Feedback.count", 1 do
      Feedback.create!(content: "Test feedback with minimum fifty characters", recipient_email: "[email protected]")
    end

    assert_no_difference "Feedback.count" do
      Feedback.new(content: nil).save
    end
  end

  test "match and instance" do
    assert_match /hello/, "hello world"
    assert_instance_of String, "hello"
    assert_respond_to "string", :upcase
  end
end

Model Testing

Testing Validations

Test required fields are valida
Полный SKILL.md на GitHub

Установить rails-ai:testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл rails-ai:testing?

Use when testing Rails applications - TDD, Minitest, fixtures, model testing, mocking, test helpers

Как установить скилл rails-ai:testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл rails-ai:testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить rails-ai:testing с