Applies ai-worker's testing discipline. Use for any task that adds or changes specs, or touches spec/** — model, service, job and request specs, spec helpers, and stubbing of claude/gh/git subprocesses.
Install
npx skillscat add hoang-phan/ai-worker/ai-worker-testing Install via the SkillsCat registry.
SKILL.md
ai-worker-testing
Layout and running
- Specs live in
spec/{models,services,jobs,requests}, mirroringapp/. Helpers:spec/rails_helper.rb,spec/spec_helper.rb. - Always run with the environment set explicitly:
RAILS_ENV=test bundle exec rspec(or a single file/line). Never rely on the default environment — it is development, which is real data. Test DB isstorage/test.sqlite3; prepare withRAILS_ENV=test bin/rails db:test:prepare. - Transactional fixtures are on (
use_transactional_fixtures = true); records created in an example roll back automatically. - CI runs the same commands in the
testjob (.github/workflows/ci.yml) and inconfig/ci.rb(bin/ci).
Data safety
- Never touch development data. No
destroy_all/delete_all/ truncate "clean slate" cleanup — rely on transactions, or delete only the exact records you created. - For
Project#local_directoryuseDir.mktmpdirand remove only that dir in anafterhook, guarded bystart_with?(Dir.tmpdir)(seespec/models/project_spec.rb).
No real external calls
- Never invoke real
claude,gh, orgitagainst the network. StubOpen3.capture3,Process.spawn,AiCli::Runner.start/.poll. - For
Git::BranchService, use a scratch local git repo created in a tmpdir (no remote), and remove only that tmpdir afterwards.
Design
- Prefer extracting pure logic into small POROs (e.g.
AiCli::Output,Prompts::StagePrompt) and unit-testing them directly, over testing through jobs or subprocesses.