Skip to content

Commit c44c91c

Browse files
arun-guptaclaude
andcommitted
fix(claude): use write_file_and_record and CONSTITUTION_REL_PATH in tests
Addresses two review comments: - ensure_context_file now uses the base class's write_file_and_record() helper instead of Path.write_text + a separate record_file_in_manifest call. This matches the pattern used everywhere else in integrations, normalizes \r\n -> \n to avoid platform newline translation, and keeps the write+manifest update consistent. - Tests now import and use CONSTITUTION_REL_PATH instead of hardcoding ".specify/memory/constitution.md", so the path stays in sync with the production constant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b9fd10d commit c44c91c

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/specify_cli/integrations/claude/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ def ensure_context_file(
189189
"If a spec is missing, incomplete, or conflicts with the constitution — stop and ask. "
190190
"Do not infer. Do not proceed.\n\n"
191191
)
192-
context_file.write_text(content, encoding="utf-8")
193-
self.record_file_in_manifest(context_file, project_root, manifest)
194-
return context_file
192+
return self.write_file_and_record(content, context_file, project_root, manifest)
195193

196194
def setup(
197195
self,

tests/integrations/test_integration_claude.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import yaml
88

9+
from specify_cli import CONSTITUTION_REL_PATH
910
from specify_cli.integrations import INTEGRATION_REGISTRY, get_integration
1011
from specify_cli.integrations.base import IntegrationBase
1112
from specify_cli.integrations.claude import ARGUMENT_HINTS
@@ -308,7 +309,7 @@ class TestClaudeMdCreation:
308309

309310
def test_ensure_context_file_creates_claude_md_when_constitution_exists(self, tmp_path):
310311
integration = get_integration("claude")
311-
constitution = tmp_path / ".specify" / "memory" / "constitution.md"
312+
constitution = tmp_path / CONSTITUTION_REL_PATH
312313
constitution.parent.mkdir(parents=True, exist_ok=True)
313314
constitution.write_text("# Constitution\n", encoding="utf-8")
314315

@@ -319,7 +320,7 @@ def test_ensure_context_file_creates_claude_md_when_constitution_exists(self, tm
319320
assert claude_md.exists()
320321
assert created == claude_md
321322
content = claude_md.read_text(encoding="utf-8")
322-
assert ".specify/memory/constitution.md" in content
323+
assert CONSTITUTION_REL_PATH.as_posix() in content
323324
for section in EXPECTED_CLAUDE_MD_SECTIONS:
324325
assert section in content, f"missing section header: {section}"
325326
for command in EXPECTED_CLAUDE_MD_COMMANDS:
@@ -335,7 +336,7 @@ def test_ensure_context_file_skips_when_constitution_missing(self, tmp_path):
335336

336337
def test_ensure_context_file_preserves_existing_claude_md(self, tmp_path):
337338
integration = get_integration("claude")
338-
constitution = tmp_path / ".specify" / "memory" / "constitution.md"
339+
constitution = tmp_path / CONSTITUTION_REL_PATH
339340
constitution.parent.mkdir(parents=True, exist_ok=True)
340341
constitution.write_text("# Constitution\n", encoding="utf-8")
341342

@@ -381,14 +382,14 @@ def test_init_cli_creates_claude_md_on_fresh_project(self, tmp_path):
381382
assert result.exit_code == 0, result.output
382383

383384
# Constitution must have been created by the init flow (not pre-seeded)
384-
constitution = project / ".specify" / "memory" / "constitution.md"
385+
constitution = project / CONSTITUTION_REL_PATH
385386
assert constitution.exists(), "init did not create the constitution"
386387

387388
# CLAUDE.md must exist and point at the constitution
388389
claude_md = project / "CLAUDE.md"
389390
assert claude_md.exists(), "init did not create CLAUDE.md"
390391
content = claude_md.read_text(encoding="utf-8")
391-
assert ".specify/memory/constitution.md" in content
392+
assert CONSTITUTION_REL_PATH.as_posix() in content
392393
for section in EXPECTED_CLAUDE_MD_SECTIONS:
393394
assert section in content, f"missing section header: {section}"
394395
for command in EXPECTED_CLAUDE_MD_COMMANDS:

0 commit comments

Comments
 (0)