When the CLI is installed, dispatch invokes the command by name.
(self, tmp_path, monkeypatch)
| 851 | assert result.error is not None |
| 852 | |
| 853 | def test_dispatch_with_mock_cli(self, tmp_path, monkeypatch): |
| 854 | """When the CLI is installed, dispatch invokes the command by name.""" |
| 855 | from unittest.mock import patch, MagicMock |
| 856 | from specify_cli.workflows.steps.command import CommandStep |
| 857 | from specify_cli.workflows.base import StepContext, StepStatus |
| 858 | |
| 859 | step = CommandStep() |
| 860 | ctx = StepContext( |
| 861 | inputs={"name": "login"}, |
| 862 | default_integration="claude", |
| 863 | project_root=str(tmp_path), |
| 864 | ) |
| 865 | config = { |
| 866 | "id": "test", |
| 867 | "command": "speckit.specify", |
| 868 | "input": {"args": "{{ inputs.name }}"}, |
| 869 | } |
| 870 | |
| 871 | mock_result = MagicMock() |
| 872 | mock_result.returncode = 0 |
| 873 | mock_result.stdout = '{"result": "done"}' |
| 874 | mock_result.stderr = "" |
| 875 | |
| 876 | with patch("specify_cli.workflows.steps.command.shutil.which", return_value="/usr/local/bin/claude"), \ |
| 877 | patch("specify_cli.integrations.base.shutil.which", return_value="/usr/local/bin/claude"), \ |
| 878 | patch("subprocess.run", return_value=mock_result) as mock_run: |
| 879 | result = step.execute(config, ctx) |
| 880 | |
| 881 | assert result.status == StepStatus.COMPLETED |
| 882 | assert result.output["dispatched"] is True |
| 883 | assert result.output["exit_code"] == 0 |
| 884 | # Verify the CLI was called with the resolved path (via shutil.which, |
| 885 | # which honors PATHEXT for ``.cmd``/``.bat`` shims on Windows), then |
| 886 | # ``-p`` and the skill invocation. |
| 887 | call_args = mock_run.call_args |
| 888 | assert call_args[0][0][0] == "/usr/local/bin/claude" |
| 889 | assert call_args[0][0][1] == "-p" |
| 890 | # Claude is a SkillsIntegration so uses /speckit-specify |
| 891 | assert "/speckit-specify login" in call_args[0][0][2] |
| 892 | |
| 893 | def test_dispatch_uses_executable_override_for_fallback_preflight(self, tmp_path, monkeypatch): |
| 894 | """Command preflight falls back to build_exec_args() argv[0].""" |
nothing calls this directly
no test coverage detected