You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+98-52Lines changed: 98 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,15 @@ Exercism Website is a comprehensive Ruby on Rails application with React/TypeScr
4
4
5
5
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
6
6
7
+
## Documentation
8
+
9
+
There is a subdirectory called `docs/llm-support` which contains detailed information that an LLM might find useful on different areas of the application. When working with specific components, always reference the RELEVANT docs in that directory first:
10
+
11
+
-`API.md` - Detailed API architecture, authentication, and patterns
12
+
-`SPI.md` - Service Provider Interface for internal AWS services
13
+
14
+
These files provide comprehensive context that supplements the workflow guidance in this document.
- Requires authentication via Bearer tokens (`Authorization: Bearer <token>`)
263
-
- Returns JSON responses
264
-
- Handles errors consistently via `render_400`, `render_403`, etc.
257
+
**API Routes (`/api`)**: Public endpoints for authenticated users (CLI, frontend, third-party integrations)
258
+
- Require Bearer token authentication
259
+
- Delegate business logic to Mandate commands
260
+
- Consistent JSON error responses
265
261
- Routes defined in `config/routes/api.rb`
266
262
267
-
#### SPI Routes (`/spi`)
268
-
The Service Provider Interface (SPI) provides internal endpoints for:
269
-
- AWS Lambda functions
270
-
- Internal microservices
271
-
- Exercism infrastructure components
272
-
273
-
**Security Model**: SPI endpoints are secured at the AWS infrastructure level rather than application-level authentication, allowing trusted internal services to post data arbitrarily.
274
-
275
-
```ruby
276
-
# Example SPI endpoints
277
-
namespace :spido
278
-
resources :tooling_jobs, only::update# Tooling service updates
279
-
resources :chatgpt_responses, only::create# AI service responses
280
-
get "solution_image_data/:track_slug/:exercise_slug/:user_handle" => "solution_image_data#show"
281
-
end
282
-
```
283
-
284
-
Key characteristics:
285
-
- No application-level authentication required
286
-
- AWS-level security controls access
263
+
**SPI Routes (`/spi`)**: Internal endpoints for AWS Lambda functions and microservices
264
+
- No application-level authentication (secured at AWS infrastructure level)
287
265
- Used by Lambda functions to post results back to main application
288
266
- Routes defined in `config/routes/spi.rb`
289
267
290
-
#### Standard Routes
291
-
Regular Rails routes handle:
292
-
- User-facing web pages
293
-
- Authentication flows (Devise)
294
-
- Webhooks (GitHub, Stripe, PayPal)
295
-
- Admin interfaces
296
-
297
-
Routes are organized in the main `config/routes.rb` with additional route files for specific features like bootcamp functionality.
268
+
**Standard Routes**: Regular Rails routes for user-facing web pages, authentication flows, webhooks, and admin interfaces.
298
269
299
270
### Configuration
300
271
-`config/database.yml` - Database configuration
@@ -333,6 +304,23 @@ This setup is complex but necessary for the full Exercism platform. When in doub
333
304
334
305
## Testing Patterns
335
306
307
+
Exercism uses **Minitest** as the testing framework with **FactoryBot** for test data generation. Tests are organized by type with comprehensive helper methods to support different testing scenarios.
308
+
309
+
### Testing Tools and Setup
310
+
311
+
**Core Testing Stack:**
312
+
-**Minitest**: Ruby's standard testing framework with assertions and test structure
313
+
-**FactoryBot**: Flexible test data generation with realistic factory definitions
314
+
-**Mocha**: Mocking and stubbing framework for isolating tests
315
+
-**Capybara**: Browser automation for system tests
316
+
-**WebMock**: HTTP request stubbing for external service integration
317
+
318
+
**Test Data Management:**
319
+
- Factories defined in `test/factories/` directory
320
+
- Use `create :user` for persisted records, `build :user` for unsaved objects
321
+
- Factory traits available for common variations: `create :user, :admin`
322
+
- Consistent data patterns ensure realistic test scenarios
323
+
336
324
### Model Tests
337
325
Model tests focus on testing every public method with small, focused tests. Tests should cover:
338
326
-**Happy path behavior**: Normal usage scenarios
@@ -401,6 +389,48 @@ class Solution::CreateTest < ActiveSupport::TestCase
401
389
end
402
390
```
403
391
392
+
### Controller Tests
393
+
Controller tests verify HTTP request handling and integration with command objects. They focus on authentication, parameter validation, and response formatting.
394
+
395
+
**API Controller Tests:**
396
+
- Inherit from `API::BaseTestCase` which provides authentication helpers
397
+
- Use `setup_user` to create authenticated test user with auth token
398
+
- Test authentication guards with `guard_incorrect_token!` class method
399
+
- Mock command objects to isolate controller logic from business logic
0 commit comments