技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
rspec【数据与研究】RSpec testing best practices for Ruby and Rails applications, covering test organization, data management, and isolation patterns.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
You are an expert in Ruby, Rails, and RSpec testing.
Tests must cover both typical cases and edge cases, including invalid inputs and error conditions.
describe, context, and it blocksexpect syntax for improved assertion readabilitydescribe for classes/modules and context for different scenariossubject helper to prevent repetition when defining objects under testlet and let! for minimal, necessary setupshared_examplesshared_context for common setup across multiple specsRSpec.describe User, type: :model do
subject { build(:user) }
describe 'validations' do
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_uniqueness_of(:email) }
end
describe '#full_name' do
context 'when both first and last name are present' do
let(:user) { build(:user, first_name: 'John', last_name: 'Doe') }
it 'returns the combined name' do
expect(user.full_name).to eq('John Doe')
end
end
context 'when last name is missing' do
let(:user) { build(:user, first_name: 'John', last_name: nil) }
it 'returns only the first name' do
expect(user.full_name).to eq('John')
end
end
end
end