RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Copilot instructions/levifig/rails-instructions

Copilot instructions

.github/instructions/rails-testing.instructions.md

Rails Testing Guide

Copilot instructions

Quality

56/100

Scores the file, not the repository.

Length

804 words

26 headings · 0 code blocks

Repository

54

— · pushed 410 days ago

Last changed

3 days ago

First indexed 3 days ago.
levifig/rails-instructions/.github/instructions/rails-testing.instructions.mdRawGitHub
1---
2description: Rails Testing Guide
3applyTo: "test/**/*_test.rb"
4---
5 
6# Rails Testing Guide
7 
8## Core Philosophy
9 
10- Test-Driven Development (TDD) as default practice
11- Use Minitest and fixtures, not RSpec or factories
12- Test behavior, not implementation details
13- Keep tests fast, focused, and reliable
14- Write tests that serve as documentation
15 
16## Testing Principles
17 
18- Write tests first, then implementation
19- One assertion per test when possible
20- Test the happy path and edge cases
21- Keep test data realistic and minimal
22- Make tests independent and repeatable
23 
24## Test Organization
25 
26- Mirror app structure in test directory
27- Group related tests in the same file
28- Use descriptive test names
29- Keep test files focused and manageable
30- Organize tests by feature or behavior
31 
32## Fixtures Best Practices
33 
34- Use fixtures for test data, not factories
35- Keep fixtures simple and realistic
36- Reference fixtures by meaningful names
37- Share fixtures across related tests
38- Update fixtures when models change
39 
40## Model Testing
41 
42- Test all validations thoroughly
43- Verify associations work correctly
44- Test scopes with various data sets
45- Check business logic and calculations
46- Ensure callbacks behave properly
47 
48## Controller Testing
49 
50- Focus on HTTP concerns only
51- Test authentication and authorization
52- Verify response formats and status codes
53- Check parameter filtering
54- Test error handling scenarios
55 
56## System Testing
57 
58- Test complete user workflows
59- Use Capybara for browser automation
60- Test JavaScript interactions
61- Verify Turbo Frame updates
62- Check responsive behavior
63 
64## Service Object Testing
65 
66- Test services in complete isolation
67- Mock external dependencies
68- Verify success and failure paths
69- Test edge cases and error conditions
70- Ensure proper transaction handling
71 
72## Integration Testing
73 
74- Test API endpoints thoroughly
75- Verify request/response cycles
76- Test authentication flows
77- Check cross-controller workflows
78- Validate data consistency
79 
80## Test Data Management
81 
82- Keep test data minimal and focused
83- Use fixtures for common scenarios
84- Create data in tests for specific cases
85- Clean up after tests when needed
86- Avoid test data dependencies
87 
88## Mocking and Stubbing
89 
90- Mock external services only
91- Avoid mocking your own objects
92- Use stubs for time-dependent code
93- Keep mocks simple and obvious
94- Document why mocking is necessary
95 
96## Test Performance
97 
98- Keep individual tests under 1 second
99- Use parallel testing for speed
100- Profile slow tests regularly
101- Optimize database operations
102- Cache expensive test setup
103 
104## Test Coverage
105 
106- Aim for high coverage without obsessing
107- Focus on critical business logic
108- Test error paths thoroughly
109- Don't test framework code
110- Use coverage as a guide, not a goal
111 
112## Continuous Integration
113 
114- Run tests on every commit
115- Keep CI builds fast
116- Fix broken tests immediately
117- Test multiple Ruby versions
118- Monitor test reliability
119 
120## Test Helpers
121 
122- Create helpers for common test patterns
123- Keep helpers focused and reusable
124- Document helper methods clearly
125- Share helpers across test types
126- Avoid complex helper logic
127 
128## Testing JavaScript
129 
130- Use system tests for JavaScript behavior
131- Test Stimulus controllers thoroughly
132- Verify Turbo interactions work
133- Check progressive enhancement
134- Test without JavaScript enabled
135 
136## API Testing
137 
138- Test all endpoints and methods
139- Verify authentication requirements
140- Check response formats and schemas
141- Test rate limiting and throttling
142- Validate error responses
143 
144## Background Job Testing
145 
146- Test job logic separately from queuing
147- Verify job parameters and execution
148- Test retry and failure scenarios
149- Check job side effects
150- Ensure idempotency
151 
152## Email Testing
153 
154- Test email delivery and content
155- Verify recipient and sender details
156- Check email templates render correctly
157- Test attachments and multipart emails
158- Validate email queueing
159 
160## Security Testing
161 
162- Test authorization for all actions
163- Verify parameter filtering works
164- Check for SQL injection vulnerabilities
165- Test CSRF protection
166- Validate input sanitization
167 
168## Performance Testing
169 
170- Profile critical code paths
171- Test with realistic data volumes
172- Monitor query counts
173- Check memory usage
174- Benchmark important operations
175 
176## Test Maintenance
177 
178- Refactor tests alongside code
179- Remove obsolete tests promptly
180- Keep tests DRY but readable
181- Update tests when requirements change
182- Review test quality regularly
183 
184## Common Anti-Patterns
185 
186- Testing implementation instead of behavior
187- Overly complex test setup
188- Brittle tests dependent on order
189- Testing framework functionality
190- Slow test suites that discourage TDD
191 
192## Debugging Tests
193 
194- Use byebug for test debugging
195- Add descriptive failure messages
196- Check test logs for details
197- Isolate failing tests
198- Verify test environment setup
199 
200## Best Practices Summary
201 
202- Write tests first
203- Keep tests simple and fast
204- Use fixtures over factories
205- Test behavior, not implementation
206- Maintain tests like production code
207 
208Remember: Tests are your safety net and documentation. Write them first, keep them simple, and maintain them well.
209 

Sections

  • Rails Testing Guide
  • Core Philosophy
  • Testing Principles
  • Test Organization
  • Fixtures Best Practices
  • Model Testing
  • Controller Testing
  • System Testing
  • Service Object Testing
  • Integration Testing
  • Test Data Management
  • Mocking and Stubbing
  • Test Performance
  • Test Coverage
  • Continuous Integration
  • Test Helpers
  • Testing JavaScript
  • API Testing
  • Background Job Testing
  • Email Testing
  • Security Testing
  • Performance Testing
  • Test Maintenance
  • Common Anti-Patterns
  • Debugging Tests
  • Best Practices Summary

What it covers

testcode-styletesting-strategysecurityapiperformance

Glob targeting

  • test/**/*_test.rb

Format

Copilot instructions

Two layers: one always-on repo file, plus optional glob-scoped instruction files. Lives under .github/ rather than the repo root, which is the tell that it is aimed at the GitHub platform surface as much as the editor.

What the corpus says about it

Repository

Owner
levifig
Language
—
License
—
Archived
no

All configs in this repo

Also in levifig/rails-instructions

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
levifig/rails-instructions.github/instructions/rails-core.instructions.md · 54Copilot instructionsunclassifiedteststylearchtesting-strategy+568/1003 days ago
levifig/rails-instructions.cursor/rules/guidelines.mdc · 54Cursor rulesunclassifiedteststyletesting-strategysecurity+471/1003 days ago
levifig/rails-instructions.cursor/rules/rails-rules.mdc · 54Cursor rulesunclassifiedtestlint-formatstylearch+984/1003 days ago
levifig/rails-instructions.github/copilot-instructions.md · 54Copilot instructionsunclassifiedteststyletesting-strategysecurity+471/1003 days ago
levifig/rails-instructions.github/instructions/rails-api.instructions.md · 54Copilot instructionsunclassifiedtestlint-formatstyletesting-strategy+767/1003 days ago
levifig/rails-instructions.github/instructions/rails-background-jobs.instructions.md · 54Copilot instructionsunclassifiedteststyletesting-strategydatabase+263/1003 days ago
levifig/rails-instructions.github/instructions/rails-controllers.instructions.md · 54Copilot instructionsunclassifiedteststylesecurityapi+156/1003 days ago
levifig/rails-instructions.github/instructions/rails-deployment.instructions.md · 54Copilot instructionsunclassifiedsetupstylesecuritydatabase+252/1003 days ago
levifig/rails-instructions.github/instructions/rails-hotwire.instructions.md · 54Copilot instructionsunclassifiedteststylesecurityperformance+156/1003 days ago
levifig/rails-instructions.github/instructions/rails-importmaps.instructions.md · 54Copilot instructionsunclassifiedteststylesecuritydatabase+256/1003 days ago
levifig/rails-instructions.github/instructions/rails-mobile.instructions.md · 54Copilot instructionsunclassifiedstyleuiperformance66/1003 days ago
levifig/rails-instructions.github/instructions/rails-models.instructions.md · 54Copilot instructionsunclassifiedteststylearchtypes+460/1003 days ago
levifig/rails-instructions.github/instructions/rails-performance.instructions.md · 54Copilot instructionsunclassifiedteststylegitdatabase+256/1003 days ago
levifig/rails-instructions.github/instructions/rails-security.instructions.md · 54Copilot instructionsunclassifiedteststylesecuritydependencies+363/1003 days ago
levifig/rails-instructions.github/instructions/rails-services.instructions.md · 54Copilot instructionsunclassifiedteststylearchtesting-strategy+475/1003 days ago
levifig/rails-instructions.github/instructions/rails-styling.instructions.md · 54Copilot instructionsunclassifiedstyledatabaseuiperformance+359/1003 days ago
levifig/rails-instructions.github/instructions/rails-views.instructions.md · 54Copilot instructionsunclassifiedteststylearchsecurity+360/1003 days ago
levifig/rails-instructions.github/instructions/rails.instructions.md · 54Copilot instructionsunclassifiedtestlint-formatstylearch+984/1003 days ago
Diff against .github/instructions/rails-core.instructions.md Diff against .cursor/rules/guidelines.mdc Diff against .cursor/rules/rails-rules.mdc Diff against .github/copilot-instructions.md Diff against .github/instructions/rails-api.instructions.md Diff against .github/instructions/rails-background-jobs.instructions.md Diff against .github/instructions/rails-controllers.instructions.md Diff against .github/instructions/rails-deployment.instructions.md Diff against .github/instructions/rails-hotwire.instructions.md Diff against .github/instructions/rails-importmaps.instructions.md Diff against .github/instructions/rails-mobile.instructions.md Diff against .github/instructions/rails-models.instructions.md Diff against .github/instructions/rails-performance.instructions.md Diff against .github/instructions/rails-security.instructions.md Diff against .github/instructions/rails-services.instructions.md Diff against .github/instructions/rails-styling.instructions.md Diff against .github/instructions/rails-views.instructions.md Diff against .github/instructions/rails.instructions.md
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack