在Visual Studio代码中运行bundle exec <command />任务

时间:2015-07-22 11:19:42

标签: macos rspec visual-studio-code

关于如何为Rspec创建任务的this教程在干净的工作环境中运行良好。

但是我安装了多个版本的RSpec,正确的任务会混淆使用哪个版本。

所以我想使用以下命令:

{ "command": "bundle exec rspec" }

但是失败了,出现以下错误:

Failed to launch external program bundle exec rspec .
spawn bundle exec rspec ENOENT

如何定义运行bundle exec rspec而不是普通rspec的(测试)任务?

1 个答案:

答案 0 :(得分:2)

感谢Hurelu在this帖子中,他解释了如何使用tasks.json中的定义构造shell命令,我已经能够定义一个可以同时运行rspec和cucumber的任务文件,使用bundle&#39 ; s exec:

{
  "command": "bundle",
  "args": ["exec"],
  "tasks": [
    {
      "suppressTaskName": true,
      "taskName": "rspec",
      "args": [ "rspec", "${file}" ],
      "isTestCommand": true
    },
    {
      "suppressTaskName": true,
      "taskName": "cucumber",
      "args": [ "cucumber", "${file}" ]
    }
  ]
}

RSpec是测试命令,因此您可以使用Cmd + Shift + T / Ctrl + Shift + t将当前文件作为RSpec测试运行。

快乐的编码!