LLM Skills
~/catalog/testing & quality//test
Testing & qualityGitHub source

Ruby test generator

/test

Create, run, and improve tests to validate changes.

davila7davila7
30.6k
May 22, 2026
MIT License
// skill content

Ruby Test Generator Create comprehensive test files with RSpec or Minitest following Ruby testing best practices. ## Purpose This command helps you quickly create test files with proper structure, examples, and testing patterns for Ruby applications. ## Usage `` /test ` ## What this command does 1. **Creates test files** with proper structure for RSpec or Minitest 2. **Includes test examples** for common scenarios 3. **Sets up test helpers** and support files 4. **Follows testing conventions** and best practices 5. **Generates factory/fixture data** when needed ## RSpec Example Output `ruby # spec/models/user_spec.rb require 'spec_helper' RSpec.describe User do let(:user) { build(:user) } let(:valid_attributes) do { name: 'John Doe', email: 'john@example.com', age: 30 } end describe 'validations' do it { should validate_presence_of(:name) } it { should validate_presence_of(:email) } it { should validate_uniqueness_of(:email) } it { should validate_numericality_of(:age).is_greater_than(0) } context 'when email format is invalid' do let(:user) { build(:user, email: 'invalid-email') } it 'is not valid' do expect(user).not_to be_valid expect(user.errors[:email]).to include('is invalid') end end end describe 'associations' do it { should have_many(:posts) } it { should have_many(:comments) } end describe 'callbacks' do describe 'before_save' do it 'normalizes email' do user = create(:user, email: 'JOHN@EXAMPLE.COM') expect(user.email).to eq('john@example.com') end end end describe 'instance methods' do describe '#full_name' do let(:user) { build(:user, first_name: 'John', last_name: 'Doe') } it 'returns the full name' do expect(user.full_name).to eq('John Doe') end context 'when last_name is missing' do let(:user) { build(:user, first_name: 'John', last_name: nil) } it 'returns only first_name' do expect(user.full_name).to eq('John') end end end describe '#active?' do context 'when user is active' do let(:user) { build(:user, status: 'active') } it 'returns true' do expect(user.active?).to be true end end context 'when user is inactive' do let(:user) { build(:user, status: 'inactive') } it 'returns false' do expect(user.active?).to be false end end end end describe 'class methods' do describe '.active' do let!(:active_user) { create(:user, status: 'active') } let!(:inactive_user) { create(:user, status: 'inactive') } it 'returns only active users' do expect(User.active).to include(active_user) expect(User.active).not_to include(inactive_user) end end describe '.find_by_email' do let!(:user) { create(:user, email: 'test@example.com') } it 'finds user by email' do found_user = User.find_by_email('test@example.com') expect(found_user).to eq(user) end it 'returns nil when user not found' do found_user = User.find_by_email('nonexistent@example.com') expect(found_user).to be_nil end end end describe 'scopes' do describe '.recent' do let!(:old_user) { create(:user, created_at: 1.year.ago) } let!(:recent_user) { create(:user, created_at: 1.day.ago) } it 'returns users created in the last 30 days' do expect(User.recent).to include(recent_user) expect(User.recent).not_to include(old_user) end end end end ` ## Minitest Example Output ``ruby # test/models/usertest.rb require 'testhelper' class UserTest < ActiveSupport::TestCase def setup @user = users(:john) @validattributes = { name: 'Jane Doe', email: 'jane@example.com', age: 25 } end # Validation tests test 'should not save user without name' do user = User.new(@validattributes.except(:name)) assertnot user.save assertincludes user.errors[:name], "can't be blank" end test 'should not save user without email' do user = User.new(@validattributes.except(:email)) assertnot user.save assertincludes user.errors[:email], "can't be blank" end test 'should not save user with invalid email' do user = User.new(@validattributes.merge(email: 'invalid-email')) assertnot user.save assertincludes user.errors[:email], 'is invalid' end test 'should not save user with duplicate email' do user1 = User.create!(@validattributes) user2 = User.new(@validattributes) assertnot user2.save assertincludes user2.errors[:email], 'has already been taken' end test 'should save user with valid attributes' do user = User.new(@valid_attr

// original public source
davila7/claude-code-templates
/cli-tool/templates/ruby/.claude/commands/test.md
License: MIT License
Independent project, not affiliated with Anthropic. This skill remains the property of its original author.
// install this skill
Paste this command in your terminal at the root of your project:
mkdir -p .claude/commands && curl -o ".claude/commands/test.md" "https://raw.githubusercontent.com/davila7/claude-code-templates/main/cli-tool/templates/ruby/.claude/commands/test.md"
Then in Claude Code, type /test to activate it.
open_in_newOpen original source
// save
Save available after sign in.
loginSign in to save
// information
Creatordavila7
Stars 30.6k
LicenseMIT License
UpdatedMay 22, 2026
Format.md
AccessFree
// similar

Skills Testing & quality

View allarrow_forward