Skip to content

Commit dfb88bb

Browse files
iamaeroplaneclaude
andcommitted
test(extensions): add CLI tests for remove confirmation pluralization
Adds TestExtensionRemoveCLI with two CliRunner tests: - singular: 1 registered command → '1 command per agent' - plural: 2 registered commands → '2 commands per agent' These prevent regressions on the cmd_count pluralization logic and the 'per agent' wording introduced in this PR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8de8cdf commit dfb88bb

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

tests/test_extensions.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3833,3 +3833,58 @@ def test_hook_message_falls_back_when_invocation_is_empty(self, project_dir):
38333833
assert "Executing: `/<missing command>`" in message
38343834
assert "EXECUTE_COMMAND: <missing command>" in message
38353835
assert "EXECUTE_COMMAND_INVOCATION: /<missing command>" in message
3836+
3837+
3838+
class TestExtensionRemoveCLI:
3839+
"""CLI tests for `specify extension remove` confirmation prompt wording."""
3840+
3841+
def _install_ext(self, project_dir, ext_dir):
3842+
"""Install extension and return the manager."""
3843+
manager = ExtensionManager(project_dir)
3844+
manager.install_from_directory(ext_dir, "0.1.0", register_commands=False)
3845+
return manager
3846+
3847+
def test_remove_confirmation_singular_command(self, tmp_path, extension_dir):
3848+
"""Confirmation prompt should say '1 command' (singular) when one command registered."""
3849+
from typer.testing import CliRunner
3850+
from unittest.mock import patch
3851+
from specify_cli import app
3852+
3853+
project_dir = tmp_path / "project"
3854+
project_dir.mkdir()
3855+
(project_dir / ".specify").mkdir()
3856+
3857+
manager = self._install_ext(project_dir, extension_dir)
3858+
# Inject registered_commands with 1 entry so cmd_count == 1
3859+
manager.registry.update("test-ext", {"registered_commands": {"claude": ["speckit.test-ext.hello"]}})
3860+
3861+
runner = CliRunner()
3862+
with patch.object(Path, "cwd", return_value=project_dir):
3863+
result = runner.invoke(
3864+
app, ["extension", "remove", "test-ext"], input="n\n", catch_exceptions=False
3865+
)
3866+
3867+
assert "1 command" in result.output
3868+
assert "1 commands" not in result.output
3869+
3870+
def test_remove_confirmation_plural_commands(self, tmp_path, extension_dir):
3871+
"""Confirmation prompt should say '2 commands' (plural) when two commands registered."""
3872+
from typer.testing import CliRunner
3873+
from unittest.mock import patch
3874+
from specify_cli import app
3875+
3876+
project_dir = tmp_path / "project"
3877+
project_dir.mkdir()
3878+
(project_dir / ".specify").mkdir()
3879+
3880+
manager = self._install_ext(project_dir, extension_dir)
3881+
# Inject registered_commands with 2 entries so cmd_count == 2
3882+
manager.registry.update("test-ext", {"registered_commands": {"claude": ["speckit.test-ext.hello", "speckit.test-ext.run"]}})
3883+
3884+
runner = CliRunner()
3885+
with patch.object(Path, "cwd", return_value=project_dir):
3886+
result = runner.invoke(
3887+
app, ["extension", "remove", "test-ext"], input="n\n", catch_exceptions=False
3888+
)
3889+
3890+
assert "2 commands" in result.output

0 commit comments

Comments
 (0)