ariadna 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ariadna.gemspec +0 -1
- data/data/agents/ariadna-codebase-mapper.md +34 -722
- data/data/agents/ariadna-debugger.md +44 -1139
- data/data/agents/ariadna-executor.md +75 -396
- data/data/agents/ariadna-planner.md +78 -1215
- data/data/agents/ariadna-roadmapper.md +55 -582
- data/data/agents/ariadna-verifier.md +60 -702
- data/data/ariadna/templates/config.json +8 -33
- data/data/ariadna/workflows/debug.md +28 -0
- data/data/ariadna/workflows/execute-phase.md +31 -513
- data/data/ariadna/workflows/map-codebase.md +20 -319
- data/data/ariadna/workflows/new-milestone.md +20 -365
- data/data/ariadna/workflows/new-project.md +19 -880
- data/data/ariadna/workflows/plan-phase.md +24 -443
- data/data/ariadna/workflows/progress.md +20 -376
- data/data/ariadna/workflows/quick.md +19 -221
- data/data/ariadna/workflows/roadmap-ops.md +28 -0
- data/data/ariadna/workflows/verify-work.md +23 -560
- data/data/commands/ariadna/add-phase.md +11 -22
- data/data/commands/ariadna/debug.md +11 -143
- data/data/commands/ariadna/execute-phase.md +12 -30
- data/data/commands/ariadna/insert-phase.md +7 -14
- data/data/commands/ariadna/map-codebase.md +16 -49
- data/data/commands/ariadna/new-milestone.md +12 -25
- data/data/commands/ariadna/new-project.md +22 -26
- data/data/commands/ariadna/plan-phase.md +13 -22
- data/data/commands/ariadna/progress.md +16 -6
- data/data/commands/ariadna/quick.md +9 -11
- data/data/commands/ariadna/remove-phase.md +9 -12
- data/data/commands/ariadna/verify-work.md +14 -19
- data/data/skills/rails-backend/API.md +138 -0
- data/data/skills/rails-backend/CONTROLLERS.md +154 -0
- data/data/skills/rails-backend/JOBS.md +132 -0
- data/data/skills/rails-backend/MODELS.md +213 -0
- data/data/skills/rails-backend/SKILL.md +169 -0
- data/data/skills/rails-frontend/ASSETS.md +154 -0
- data/data/skills/rails-frontend/COMPONENTS.md +253 -0
- data/data/skills/rails-frontend/SKILL.md +187 -0
- data/data/skills/rails-frontend/VIEWS.md +168 -0
- data/data/skills/rails-performance/PROFILING.md +106 -0
- data/data/skills/rails-performance/SKILL.md +217 -0
- data/data/skills/rails-security/AUDIT.md +118 -0
- data/data/skills/rails-security/SKILL.md +422 -0
- data/data/skills/rails-testing/FIXTURES.md +78 -0
- data/data/skills/rails-testing/SKILL.md +160 -0
- data/data/skills/rails-testing/SYSTEM-TESTS.md +73 -0
- data/lib/ariadna/installer.rb +11 -15
- data/lib/ariadna/tools/cli.rb +0 -12
- data/lib/ariadna/tools/config_manager.rb +10 -72
- data/lib/ariadna/tools/frontmatter.rb +23 -1
- data/lib/ariadna/tools/init.rb +201 -401
- data/lib/ariadna/tools/model_profiles.rb +6 -14
- data/lib/ariadna/tools/phase_manager.rb +1 -10
- data/lib/ariadna/tools/state_manager.rb +170 -451
- data/lib/ariadna/tools/template_filler.rb +4 -12
- data/lib/ariadna/tools/verification.rb +21 -399
- data/lib/ariadna/uninstaller.rb +9 -0
- data/lib/ariadna/version.rb +1 -1
- data/lib/ariadna.rb +1 -0
- metadata +20 -91
- data/data/agents/ariadna-backend-executor.md +0 -261
- data/data/agents/ariadna-frontend-executor.md +0 -259
- data/data/agents/ariadna-integration-checker.md +0 -418
- data/data/agents/ariadna-phase-researcher.md +0 -469
- data/data/agents/ariadna-plan-checker.md +0 -622
- data/data/agents/ariadna-project-researcher.md +0 -618
- data/data/agents/ariadna-research-synthesizer.md +0 -236
- data/data/agents/ariadna-test-executor.md +0 -266
- data/data/ariadna/references/checkpoints.md +0 -772
- data/data/ariadna/references/continuation-format.md +0 -249
- data/data/ariadna/references/decimal-phase-calculation.md +0 -65
- data/data/ariadna/references/git-integration.md +0 -248
- data/data/ariadna/references/git-planning-commit.md +0 -38
- data/data/ariadna/references/model-profile-resolution.md +0 -32
- data/data/ariadna/references/model-profiles.md +0 -73
- data/data/ariadna/references/phase-argument-parsing.md +0 -61
- data/data/ariadna/references/planning-config.md +0 -194
- data/data/ariadna/references/questioning.md +0 -153
- data/data/ariadna/references/rails-conventions.md +0 -416
- data/data/ariadna/references/tdd.md +0 -267
- data/data/ariadna/references/ui-brand.md +0 -160
- data/data/ariadna/references/verification-patterns.md +0 -853
- data/data/ariadna/templates/codebase/architecture.md +0 -481
- data/data/ariadna/templates/codebase/concerns.md +0 -380
- data/data/ariadna/templates/codebase/conventions.md +0 -434
- data/data/ariadna/templates/codebase/integrations.md +0 -328
- data/data/ariadna/templates/codebase/stack.md +0 -189
- data/data/ariadna/templates/codebase/structure.md +0 -418
- data/data/ariadna/templates/codebase/testing.md +0 -606
- data/data/ariadna/templates/context.md +0 -283
- data/data/ariadna/templates/continue-here.md +0 -78
- data/data/ariadna/templates/debug-subagent-prompt.md +0 -91
- data/data/ariadna/templates/phase-prompt.md +0 -609
- data/data/ariadna/templates/planner-subagent-prompt.md +0 -117
- data/data/ariadna/templates/research-project/ARCHITECTURE.md +0 -439
- data/data/ariadna/templates/research-project/FEATURES.md +0 -168
- data/data/ariadna/templates/research-project/PITFALLS.md +0 -406
- data/data/ariadna/templates/research-project/STACK.md +0 -251
- data/data/ariadna/templates/research-project/SUMMARY.md +0 -247
- data/data/ariadna/templates/state.md +0 -176
- data/data/ariadna/templates/summary-complex.md +0 -59
- data/data/ariadna/templates/summary-minimal.md +0 -41
- data/data/ariadna/templates/summary-standard.md +0 -48
- data/data/ariadna/templates/user-setup.md +0 -310
- data/data/ariadna/workflows/add-phase.md +0 -111
- data/data/ariadna/workflows/add-todo.md +0 -157
- data/data/ariadna/workflows/audit-milestone.md +0 -241
- data/data/ariadna/workflows/check-todos.md +0 -176
- data/data/ariadna/workflows/complete-milestone.md +0 -644
- data/data/ariadna/workflows/diagnose-issues.md +0 -219
- data/data/ariadna/workflows/discovery-phase.md +0 -289
- data/data/ariadna/workflows/discuss-phase.md +0 -408
- data/data/ariadna/workflows/execute-plan.md +0 -448
- data/data/ariadna/workflows/help.md +0 -470
- data/data/ariadna/workflows/insert-phase.md +0 -129
- data/data/ariadna/workflows/list-phase-assumptions.md +0 -178
- data/data/ariadna/workflows/pause-work.md +0 -122
- data/data/ariadna/workflows/plan-milestone-gaps.md +0 -256
- data/data/ariadna/workflows/remove-phase.md +0 -154
- data/data/ariadna/workflows/research-phase.md +0 -74
- data/data/ariadna/workflows/resume-project.md +0 -306
- data/data/ariadna/workflows/set-profile.md +0 -80
- data/data/ariadna/workflows/settings.md +0 -145
- data/data/ariadna/workflows/transition.md +0 -493
- data/data/ariadna/workflows/update.md +0 -212
- data/data/ariadna/workflows/verify-phase.md +0 -226
- data/data/commands/ariadna/add-todo.md +0 -42
- data/data/commands/ariadna/audit-milestone.md +0 -42
- data/data/commands/ariadna/check-todos.md +0 -41
- data/data/commands/ariadna/complete-milestone.md +0 -136
- data/data/commands/ariadna/discuss-phase.md +0 -86
- data/data/commands/ariadna/help.md +0 -22
- data/data/commands/ariadna/list-phase-assumptions.md +0 -50
- data/data/commands/ariadna/pause-work.md +0 -35
- data/data/commands/ariadna/plan-milestone-gaps.md +0 -40
- data/data/commands/ariadna/reapply-patches.md +0 -110
- data/data/commands/ariadna/research-phase.md +0 -187
- data/data/commands/ariadna/resume-work.md +0 -40
- data/data/commands/ariadna/set-profile.md +0 -34
- data/data/commands/ariadna/settings.md +0 -36
- data/data/commands/ariadna/update.md +0 -37
- data/data/guides/backend.md +0 -3069
- data/data/guides/frontend.md +0 -1479
- data/data/guides/performance.md +0 -1193
- data/data/guides/security.md +0 -1522
- data/data/guides/style-guide.md +0 -1091
- data/data/guides/testing.md +0 -504
- data/data/templates.md +0 -94
|
@@ -1,606 +0,0 @@
|
|
|
1
|
-
# Testing Patterns Template
|
|
2
|
-
|
|
3
|
-
Template for `.ariadna_planning/codebase/TESTING.md` - captures test framework and patterns.
|
|
4
|
-
|
|
5
|
-
**Purpose:** Document how tests are written and run. Guide for adding tests that match existing patterns.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## File Template
|
|
10
|
-
|
|
11
|
-
```markdown
|
|
12
|
-
# Testing Patterns
|
|
13
|
-
|
|
14
|
-
**Analysis Date:** [YYYY-MM-DD]
|
|
15
|
-
|
|
16
|
-
## Test Framework
|
|
17
|
-
|
|
18
|
-
**Runner:**
|
|
19
|
-
- [Framework: e.g., "Minitest 5.x (Rails default, stdlib)"]
|
|
20
|
-
- [Config: e.g., "`test/test_helper.rb`"]
|
|
21
|
-
|
|
22
|
-
**Assertions:**
|
|
23
|
-
- [Core: e.g., "`assert`, `assert_equal`, `assert_nil`, `assert_raises`, `assert_not`, `refute`"]
|
|
24
|
-
- [Rails: e.g., "`assert_difference`, `assert_no_difference`, `assert_changes`, `assert_includes`"]
|
|
25
|
-
- [Controller: e.g., "`assert_response`, `assert_redirected_to`, `assert_enqueued_with`"]
|
|
26
|
-
|
|
27
|
-
**Run Commands:**
|
|
28
|
-
```bash
|
|
29
|
-
[e.g., "bundle exec rake test"] # Run all tests
|
|
30
|
-
[e.g., "bin/rails test"] # Rails test runner
|
|
31
|
-
[e.g., "bin/rails test test/models/user_test.rb"] # Single file
|
|
32
|
-
[e.g., "bin/rails test test/models/"] # Directory
|
|
33
|
-
[e.g., "bin/rails test:system"] # System tests
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Test File Organization
|
|
37
|
-
|
|
38
|
-
**Location:**
|
|
39
|
-
- [Pattern: e.g., "`test/` directory mirroring `app/` structure"]
|
|
40
|
-
- [Models: e.g., "`test/models/`"]
|
|
41
|
-
- [Controllers: e.g., "`test/controllers/`"]
|
|
42
|
-
- [Integration: e.g., "`test/integration/`"]
|
|
43
|
-
- [System: e.g., "`test/system/`"]
|
|
44
|
-
|
|
45
|
-
**Naming:**
|
|
46
|
-
- [Convention: e.g., "`*_test.rb` suffix for all test files"]
|
|
47
|
-
- [Models: e.g., "`test/models/card_test.rb`"]
|
|
48
|
-
- [Concerns: e.g., "`test/models/card/closeable_test.rb`"]
|
|
49
|
-
|
|
50
|
-
**Structure:**
|
|
51
|
-
```
|
|
52
|
-
[Show actual directory pattern, e.g.:
|
|
53
|
-
test/
|
|
54
|
-
test_helper.rb
|
|
55
|
-
models/
|
|
56
|
-
card_test.rb
|
|
57
|
-
card/
|
|
58
|
-
closeable_test.rb
|
|
59
|
-
golden_test.rb
|
|
60
|
-
controllers/
|
|
61
|
-
cards_controller_test.rb
|
|
62
|
-
cards/
|
|
63
|
-
closures_controller_test.rb
|
|
64
|
-
integration/
|
|
65
|
-
card_lifecycle_test.rb
|
|
66
|
-
system/
|
|
67
|
-
card_management_test.rb
|
|
68
|
-
fixtures/
|
|
69
|
-
cards.yml
|
|
70
|
-
users.yml
|
|
71
|
-
sessions.yml
|
|
72
|
-
]
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Test Structure
|
|
76
|
-
|
|
77
|
-
**Suite Organization:**
|
|
78
|
-
```ruby
|
|
79
|
-
[Show actual pattern used, e.g.:
|
|
80
|
-
|
|
81
|
-
require "test_helper"
|
|
82
|
-
|
|
83
|
-
class CardTest < ActiveSupport::TestCase
|
|
84
|
-
setup do
|
|
85
|
-
@card = cards(:open_card)
|
|
86
|
-
Current.session = sessions(:david)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
test "validates presence of title" do
|
|
90
|
-
@card.title = nil
|
|
91
|
-
assert_not @card.valid?
|
|
92
|
-
assert_includes @card.errors[:title], "can't be blank"
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
test "generates sequential number" do
|
|
96
|
-
card = Card.create!(board: boards(:main_board), title: "New card")
|
|
97
|
-
assert card.number.positive?
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
]
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
**Patterns:**
|
|
104
|
-
- [Setup: e.g., "`setup` block for per-test state, always set `Current.session`"]
|
|
105
|
-
- [Teardown: e.g., "Rarely needed — database transactions roll back automatically"]
|
|
106
|
-
- [Structure: e.g., "`test \"description\"` blocks for clarity"]
|
|
107
|
-
- [Focus: e.g., "One concept per test"]
|
|
108
|
-
|
|
109
|
-
## Mocking
|
|
110
|
-
|
|
111
|
-
**Framework:**
|
|
112
|
-
- [Tool: e.g., "`Minitest::Mock` for mock objects, `stub` for method stubbing"]
|
|
113
|
-
- [Time: e.g., "`travel_to` for time-dependent tests (ActiveSupport)"]
|
|
114
|
-
|
|
115
|
-
**Patterns:**
|
|
116
|
-
```ruby
|
|
117
|
-
[Show actual mocking pattern, e.g.:
|
|
118
|
-
|
|
119
|
-
# Minitest::Mock
|
|
120
|
-
mock = Minitest::Mock.new
|
|
121
|
-
mock.expect :call, "result", [String]
|
|
122
|
-
|
|
123
|
-
# Stub
|
|
124
|
-
User.stub :find, @user do
|
|
125
|
-
get user_url(@user)
|
|
126
|
-
assert_response :success
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
# Time travel
|
|
130
|
-
travel_to Time.zone.parse("2025-01-15 10:00") do
|
|
131
|
-
assert card.stale?
|
|
132
|
-
end
|
|
133
|
-
]
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**What to Mock:**
|
|
137
|
-
- [e.g., "External HTTP calls (APIs, webhooks)"]
|
|
138
|
-
- [e.g., "Email delivery (use ActionMailer test helpers)"]
|
|
139
|
-
- [e.g., "Time-dependent code (`travel_to`)"]
|
|
140
|
-
- [e.g., "File system operations"]
|
|
141
|
-
|
|
142
|
-
**What NOT to Mock:**
|
|
143
|
-
- [e.g., "ActiveRecord queries (use fixtures)"]
|
|
144
|
-
- [e.g., "Pure Ruby methods"]
|
|
145
|
-
- [e.g., "Internal business logic"]
|
|
146
|
-
|
|
147
|
-
## Fixtures
|
|
148
|
-
|
|
149
|
-
**Test Data:**
|
|
150
|
-
```yaml
|
|
151
|
-
[Show actual fixture pattern, e.g.:
|
|
152
|
-
|
|
153
|
-
# test/fixtures/cards.yml
|
|
154
|
-
open_card:
|
|
155
|
-
title: "Fix login bug"
|
|
156
|
-
board: main_board
|
|
157
|
-
creator: david
|
|
158
|
-
number: 1
|
|
159
|
-
|
|
160
|
-
closed_card:
|
|
161
|
-
title: "Update docs"
|
|
162
|
-
board: main_board
|
|
163
|
-
creator: david
|
|
164
|
-
number: 2
|
|
165
|
-
]
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
```ruby
|
|
169
|
-
[Show fixture access pattern, e.g.:
|
|
170
|
-
|
|
171
|
-
# Accessing fixtures in tests
|
|
172
|
-
@card = cards(:open_card)
|
|
173
|
-
@user = users(:david)
|
|
174
|
-
Current.session = sessions(:david)
|
|
175
|
-
]
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
**Location:**
|
|
179
|
-
- [e.g., "`test/fixtures/` for YAML fixtures (Rails default)"]
|
|
180
|
-
- [e.g., "`test/factories/` for FactoryBot factories (if present)"]
|
|
181
|
-
|
|
182
|
-
## Coverage
|
|
183
|
-
|
|
184
|
-
**Requirements:**
|
|
185
|
-
- [Target: e.g., "No enforced target, focus on models and business logic"]
|
|
186
|
-
- [Tool: e.g., "SimpleCov for coverage tracking"]
|
|
187
|
-
|
|
188
|
-
**View Coverage:**
|
|
189
|
-
```bash
|
|
190
|
-
[e.g., "COVERAGE=true bundle exec rake test"]
|
|
191
|
-
[e.g., "open coverage/index.html"]
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Test Types
|
|
195
|
-
|
|
196
|
-
**Model Tests:**
|
|
197
|
-
- [Location: e.g., "`test/models/`"]
|
|
198
|
-
- [Scope: e.g., "Validations, associations, scopes, concern behavior, business logic methods"]
|
|
199
|
-
- [Setup: e.g., "Fixtures + `Current.session` for request context"]
|
|
200
|
-
|
|
201
|
-
**Controller Tests:**
|
|
202
|
-
- [Location: e.g., "`test/controllers/`"]
|
|
203
|
-
- [Scope: e.g., "Request/response, params, auth, redirects, Turbo Stream responses"]
|
|
204
|
-
- [Setup: e.g., "Sign in via session fixture, use URL helpers"]
|
|
205
|
-
|
|
206
|
-
**Integration Tests:**
|
|
207
|
-
- [Location: e.g., "`test/integration/`"]
|
|
208
|
-
- [Scope: e.g., "Multi-step flows, API endpoints, cross-controller interactions"]
|
|
209
|
-
|
|
210
|
-
**System Tests:**
|
|
211
|
-
- [Location: e.g., "`test/system/`"]
|
|
212
|
-
- [Scope: e.g., "Browser tests with Capybara"]
|
|
213
|
-
- [Driver: e.g., "`driven_by :selenium, using: :headless_chrome`"]
|
|
214
|
-
|
|
215
|
-
## Common Patterns
|
|
216
|
-
|
|
217
|
-
**Assert Database Changes:**
|
|
218
|
-
```ruby
|
|
219
|
-
[Show pattern, e.g.:
|
|
220
|
-
|
|
221
|
-
assert_difference "Event.count", 1 do
|
|
222
|
-
@card.close
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
assert_no_difference "Card.count" do
|
|
226
|
-
post cards_url, params: { card: { title: "" } }
|
|
227
|
-
end
|
|
228
|
-
]
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
**Assert Attribute Changes:**
|
|
232
|
-
```ruby
|
|
233
|
-
[Show pattern, e.g.:
|
|
234
|
-
|
|
235
|
-
assert_changes -> { @card.reload.title }, from: "Old", to: "New" do
|
|
236
|
-
@card.update!(title: "New")
|
|
237
|
-
end
|
|
238
|
-
]
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
**Controller Tests:**
|
|
242
|
-
```ruby
|
|
243
|
-
[Show pattern, e.g.:
|
|
244
|
-
|
|
245
|
-
test "creates card" do
|
|
246
|
-
assert_difference "Card.count", 1 do
|
|
247
|
-
post cards_url, params: { card: { title: "New card" } }
|
|
248
|
-
end
|
|
249
|
-
assert_redirected_to card_url(Card.last)
|
|
250
|
-
end
|
|
251
|
-
]
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
**System Tests:**
|
|
255
|
-
```ruby
|
|
256
|
-
[Show pattern, e.g.:
|
|
257
|
-
|
|
258
|
-
test "user closes a card" do
|
|
259
|
-
visit card_url(@card)
|
|
260
|
-
click_on "Close"
|
|
261
|
-
assert_text "Card closed"
|
|
262
|
-
end
|
|
263
|
-
]
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
*Testing analysis: [date]*
|
|
269
|
-
*Update when test patterns change*
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
<good_examples>
|
|
273
|
-
```markdown
|
|
274
|
-
# Testing Patterns
|
|
275
|
-
|
|
276
|
-
**Analysis Date:** 2025-01-20
|
|
277
|
-
|
|
278
|
-
## Test Framework
|
|
279
|
-
|
|
280
|
-
**Runner:**
|
|
281
|
-
- Minitest 5.x (Rails default, stdlib)
|
|
282
|
-
- Config: `test/test_helper.rb`
|
|
283
|
-
|
|
284
|
-
**Assertions:**
|
|
285
|
-
- Core: `assert`, `assert_equal`, `assert_nil`, `assert_raises`, `assert_not`, `refute`, `assert_includes`
|
|
286
|
-
- Rails: `assert_difference`, `assert_no_difference`, `assert_changes`, `assert_no_changes`
|
|
287
|
-
- Controller: `assert_response`, `assert_redirected_to`, `assert_enqueued_with`, `assert_enqueued_jobs`
|
|
288
|
-
|
|
289
|
-
**Run Commands:**
|
|
290
|
-
```bash
|
|
291
|
-
bundle exec rake test # Run all tests
|
|
292
|
-
bin/rails test # Rails test runner
|
|
293
|
-
bin/rails test test/models/card_test.rb # Single file
|
|
294
|
-
bin/rails test test/models/ # Directory
|
|
295
|
-
bin/rails test:system # System tests
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## Test File Organization
|
|
299
|
-
|
|
300
|
-
**Location:**
|
|
301
|
-
- `test/` directory mirroring `app/` structure
|
|
302
|
-
- Model-specific concern tests in subdirectories
|
|
303
|
-
|
|
304
|
-
**Naming:**
|
|
305
|
-
- `*_test.rb` suffix for all test files
|
|
306
|
-
- Concern tests mirror concern structure: `test/models/card/closeable_test.rb`
|
|
307
|
-
|
|
308
|
-
**Structure:**
|
|
309
|
-
```
|
|
310
|
-
test/
|
|
311
|
-
test_helper.rb
|
|
312
|
-
models/
|
|
313
|
-
card_test.rb
|
|
314
|
-
board_test.rb
|
|
315
|
-
user_test.rb
|
|
316
|
-
card/
|
|
317
|
-
closeable_test.rb
|
|
318
|
-
golden_test.rb
|
|
319
|
-
postponable_test.rb
|
|
320
|
-
controllers/
|
|
321
|
-
cards_controller_test.rb
|
|
322
|
-
cards/
|
|
323
|
-
closures_controller_test.rb
|
|
324
|
-
goldnesses_controller_test.rb
|
|
325
|
-
integration/
|
|
326
|
-
card_lifecycle_test.rb
|
|
327
|
-
system/
|
|
328
|
-
card_management_test.rb
|
|
329
|
-
fixtures/
|
|
330
|
-
cards.yml
|
|
331
|
-
boards.yml
|
|
332
|
-
users.yml
|
|
333
|
-
sessions.yml
|
|
334
|
-
closures.yml
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
## Test Structure
|
|
338
|
-
|
|
339
|
-
**Suite Organization:**
|
|
340
|
-
```ruby
|
|
341
|
-
require "test_helper"
|
|
342
|
-
|
|
343
|
-
class CardTest < ActiveSupport::TestCase
|
|
344
|
-
setup do
|
|
345
|
-
@card = cards(:open_card)
|
|
346
|
-
Current.session = sessions(:david)
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
test "closes card" do
|
|
350
|
-
assert_difference "Closure.count", 1 do
|
|
351
|
-
@card.close
|
|
352
|
-
end
|
|
353
|
-
assert @card.closed?
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
test "cannot close already closed card" do
|
|
357
|
-
@card.close
|
|
358
|
-
assert_no_difference "Closure.count" do
|
|
359
|
-
@card.close
|
|
360
|
-
end
|
|
361
|
-
end
|
|
362
|
-
end
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
**Patterns:**
|
|
366
|
-
- `setup` block for per-test state — always set `Current.session`
|
|
367
|
-
- Database transactions roll back after each test — teardown rarely needed
|
|
368
|
-
- `test "description"` blocks for clarity (not `def test_*`)
|
|
369
|
-
- One concept per test
|
|
370
|
-
|
|
371
|
-
## Mocking
|
|
372
|
-
|
|
373
|
-
**Framework:**
|
|
374
|
-
- `Minitest::Mock` for mock objects
|
|
375
|
-
- `stub` for method stubbing (stdlib, no extra gems)
|
|
376
|
-
- `travel_to` for time-dependent tests (ActiveSupport)
|
|
377
|
-
|
|
378
|
-
**Patterns:**
|
|
379
|
-
```ruby
|
|
380
|
-
# Minitest::Mock
|
|
381
|
-
mock = Minitest::Mock.new
|
|
382
|
-
mock.expect :call, "result", [String]
|
|
383
|
-
service = MyService.new(dependency: mock)
|
|
384
|
-
service.perform
|
|
385
|
-
mock.verify
|
|
386
|
-
|
|
387
|
-
# Stub
|
|
388
|
-
User.stub :find, @user do
|
|
389
|
-
get user_url(@user)
|
|
390
|
-
assert_response :success
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
# Time travel
|
|
394
|
-
travel_to Time.zone.parse("2025-01-15 10:00") do
|
|
395
|
-
assert card.stale?
|
|
396
|
-
end
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
**What to Mock:**
|
|
400
|
-
- External HTTP calls (APIs, webhooks)
|
|
401
|
-
- Email delivery (use ActionMailer test helpers)
|
|
402
|
-
- Time-dependent code (`travel_to`)
|
|
403
|
-
- File system operations
|
|
404
|
-
|
|
405
|
-
**What NOT to Mock:**
|
|
406
|
-
- ActiveRecord queries (use fixtures)
|
|
407
|
-
- Pure Ruby methods
|
|
408
|
-
- Internal business logic
|
|
409
|
-
|
|
410
|
-
## Fixtures
|
|
411
|
-
|
|
412
|
-
**Test Data:**
|
|
413
|
-
```yaml
|
|
414
|
-
# test/fixtures/cards.yml
|
|
415
|
-
open_card:
|
|
416
|
-
title: "Fix login bug"
|
|
417
|
-
board: main_board
|
|
418
|
-
creator: david
|
|
419
|
-
number: 1
|
|
420
|
-
|
|
421
|
-
closed_card:
|
|
422
|
-
title: "Update docs"
|
|
423
|
-
board: main_board
|
|
424
|
-
creator: david
|
|
425
|
-
number: 2
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
```ruby
|
|
429
|
-
# Accessing fixtures in tests
|
|
430
|
-
@card = cards(:open_card)
|
|
431
|
-
@user = users(:david)
|
|
432
|
-
Current.session = sessions(:david)
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
**Location:**
|
|
436
|
-
- `test/fixtures/` for YAML fixtures (Rails default)
|
|
437
|
-
- Fixture-based testing preferred over FactoryBot — faster, deterministic, no build overhead
|
|
438
|
-
- Fixture associations use label references (not IDs): `board: main_board`
|
|
439
|
-
|
|
440
|
-
**Current Context in Tests:**
|
|
441
|
-
- `Current.session = sessions(:fixture_name)` sets up the full cascade: session -> identity -> user
|
|
442
|
-
- Required whenever model code references `Current.user` (e.g., lambda defaults on `belongs_to :creator`)
|
|
443
|
-
- Set in `setup` block so every test has proper context
|
|
444
|
-
|
|
445
|
-
## Coverage
|
|
446
|
-
|
|
447
|
-
**Requirements:**
|
|
448
|
-
- No enforced coverage target
|
|
449
|
-
- Focus on models and business logic
|
|
450
|
-
- SimpleCov for coverage tracking
|
|
451
|
-
|
|
452
|
-
**View Coverage:**
|
|
453
|
-
```bash
|
|
454
|
-
COVERAGE=true bundle exec rake test
|
|
455
|
-
open coverage/index.html
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
## Test Types
|
|
459
|
-
|
|
460
|
-
**Model Tests:**
|
|
461
|
-
- Location: `test/models/`
|
|
462
|
-
- Scope: Validations, associations, scopes, concern behavior, business logic methods
|
|
463
|
-
- Setup: Fixtures + `Current.session` for request context
|
|
464
|
-
- Examples: `card_test.rb`, `card/closeable_test.rb`, `board_test.rb`
|
|
465
|
-
|
|
466
|
-
**Controller Tests:**
|
|
467
|
-
- Location: `test/controllers/`
|
|
468
|
-
- Scope: Request/response, params, auth, redirects, Turbo Stream responses
|
|
469
|
-
- Setup: Sign in via session fixture, use URL helpers
|
|
470
|
-
- Examples: `cards_controller_test.rb`, `cards/closures_controller_test.rb`
|
|
471
|
-
|
|
472
|
-
**Integration Tests:**
|
|
473
|
-
- Location: `test/integration/`
|
|
474
|
-
- Scope: Multi-step flows, API endpoints, cross-controller interactions
|
|
475
|
-
- Examples: `card_lifecycle_test.rb`
|
|
476
|
-
|
|
477
|
-
**System Tests:**
|
|
478
|
-
- Location: `test/system/`
|
|
479
|
-
- Scope: Full browser tests with Capybara
|
|
480
|
-
- Driver: `driven_by :selenium, using: :headless_chrome`
|
|
481
|
-
- Examples: `card_management_test.rb`
|
|
482
|
-
|
|
483
|
-
## Common Patterns
|
|
484
|
-
|
|
485
|
-
**Assert Database Changes:**
|
|
486
|
-
```ruby
|
|
487
|
-
# Assert a record is created
|
|
488
|
-
assert_difference "Event.count", 1 do
|
|
489
|
-
@card.close
|
|
490
|
-
end
|
|
491
|
-
|
|
492
|
-
# Assert no records created (e.g., invalid input)
|
|
493
|
-
assert_no_difference "Card.count" do
|
|
494
|
-
post cards_url, params: { card: { title: "" } }
|
|
495
|
-
end
|
|
496
|
-
|
|
497
|
-
# Assert multiple changes
|
|
498
|
-
assert_difference -> { Card::Archive.count }, +1 do
|
|
499
|
-
assert_difference -> { Event.count }, +1 do
|
|
500
|
-
@card.archive
|
|
501
|
-
end
|
|
502
|
-
end
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
**Assert Attribute Changes:**
|
|
506
|
-
```ruby
|
|
507
|
-
assert_changes -> { @card.reload.title }, from: "Old", to: "New" do
|
|
508
|
-
@card.update!(title: "New")
|
|
509
|
-
end
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
**Controller Tests:**
|
|
513
|
-
```ruby
|
|
514
|
-
test "creates card" do
|
|
515
|
-
assert_difference "Card.count", 1 do
|
|
516
|
-
post cards_url, params: { card: { title: "New card" } }
|
|
517
|
-
end
|
|
518
|
-
assert_redirected_to card_url(Card.last)
|
|
519
|
-
end
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
**Job Enqueue Tests:**
|
|
523
|
-
```ruby
|
|
524
|
-
test "notify_recipients_later enqueues job" do
|
|
525
|
-
assert_enqueued_with(job: NotifyRecipientsJob) do
|
|
526
|
-
comment.save!
|
|
527
|
-
end
|
|
528
|
-
end
|
|
529
|
-
|
|
530
|
-
# Or test with inline execution
|
|
531
|
-
test "job processes in correct account" do
|
|
532
|
-
perform_enqueued_jobs do
|
|
533
|
-
comment.notify_recipients_later
|
|
534
|
-
end
|
|
535
|
-
assert_equal 2, Current.account.notifications.count
|
|
536
|
-
end
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
**System Tests:**
|
|
540
|
-
```ruby
|
|
541
|
-
test "user closes a card" do
|
|
542
|
-
visit card_url(@card)
|
|
543
|
-
click_on "Close"
|
|
544
|
-
assert_text "Card closed"
|
|
545
|
-
end
|
|
546
|
-
```
|
|
547
|
-
|
|
548
|
-
---
|
|
549
|
-
|
|
550
|
-
*Testing analysis: 2025-01-20*
|
|
551
|
-
*Update when test patterns change*
|
|
552
|
-
```
|
|
553
|
-
</good_examples>
|
|
554
|
-
|
|
555
|
-
<guidelines>
|
|
556
|
-
**What belongs in TESTING.md:**
|
|
557
|
-
- Test framework and runner configuration
|
|
558
|
-
- Test file location and naming patterns
|
|
559
|
-
- Test structure (`setup`, `test "description"` blocks)
|
|
560
|
-
- Mocking approach and examples (`Minitest::Mock`, `stub`, `travel_to`)
|
|
561
|
-
- Fixture patterns and `Current.session` setup
|
|
562
|
-
- Coverage requirements
|
|
563
|
-
- How to run tests (commands)
|
|
564
|
-
- Common testing patterns in actual code (`assert_difference`, `assert_changes`, job enqueue assertions)
|
|
565
|
-
|
|
566
|
-
**What does NOT belong here:**
|
|
567
|
-
- Specific test cases (defer to actual test files)
|
|
568
|
-
- Technology choices (that's STACK.md)
|
|
569
|
-
- CI/CD setup (that's deployment docs)
|
|
570
|
-
|
|
571
|
-
**When filling this template:**
|
|
572
|
-
- Check `Gemfile` for test framework (Minitest is Rails default — check if RSpec is present instead)
|
|
573
|
-
- Read `test/test_helper.rb` for test configuration, included modules, global setup
|
|
574
|
-
- Examine `test/` directory structure for organization patterns
|
|
575
|
-
- Check for `test/fixtures/` (Rails default) vs `test/factories/` (FactoryBot)
|
|
576
|
-
- Read 3-5 existing test files to identify patterns (setup, assertions, fixture usage)
|
|
577
|
-
- Look for test support in `test/support/` or custom helpers in `test/test_helper.rb`
|
|
578
|
-
- Check for `Current.session` setup patterns in model tests
|
|
579
|
-
- Note whether concern tests exist in subdirectories (`test/models/card/`)
|
|
580
|
-
- Document actual patterns used, not ideal patterns
|
|
581
|
-
|
|
582
|
-
**Key Rails testing conventions to note:**
|
|
583
|
-
- Fixture-based testing is Rails default (vs FactoryBot) — faster, deterministic
|
|
584
|
-
- `Current.session = sessions(:fixture_name)` pattern for setting up request context in tests
|
|
585
|
-
- `assert_difference` / `assert_no_difference` as the primary pattern for testing state changes
|
|
586
|
-
- Concern tests mirror concern file structure (`test/models/card/closeable_test.rb`)
|
|
587
|
-
- System tests use Capybara with `driven_by :selenium, using: :headless_chrome`
|
|
588
|
-
|
|
589
|
-
**Useful for phase planning when:**
|
|
590
|
-
- Adding new features (write matching tests)
|
|
591
|
-
- Adding new concerns (create corresponding concern test file)
|
|
592
|
-
- Refactoring (maintain test patterns)
|
|
593
|
-
- Fixing bugs (add regression tests using `assert_difference`)
|
|
594
|
-
- Understanding verification approach
|
|
595
|
-
- Setting up test infrastructure
|
|
596
|
-
|
|
597
|
-
**Analysis approach:**
|
|
598
|
-
- Check `Gemfile` for test framework and related gems (minitest, capybara, selenium-webdriver, simplecov)
|
|
599
|
-
- Read `test/test_helper.rb` for configuration, required files, global setup
|
|
600
|
-
- Examine `test/` directory structure (does it mirror `app/`? are concern tests in subdirectories?)
|
|
601
|
-
- Check for `test/fixtures/` and examine fixture files for association patterns
|
|
602
|
-
- Review 5 test files for patterns (setup blocks, `Current.session` usage, assertion style, fixture access)
|
|
603
|
-
- Look for test utilities in `test/support/` or custom assertions
|
|
604
|
-
- Note test types present (model, controller, integration, system)
|
|
605
|
-
- Document commands for running tests (`bin/rails test`, `bundle exec rake test`)
|
|
606
|
-
</guidelines>
|