1

Following this tutorial on how to make a task for Rspec works great, in a clean working environment.

But I have multiple versions of RSpec installed and the task, correctly, gets confused which version to use.

So I want to use the following command:

{ "command": "bundle exec rspec" }

This fails though, with the following error:

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

How can I define a (test) task to that runs bundle exec rspec instead of plain rspec?

Nick F
  • 9,781
  • 7
  • 75
  • 90

1 Answers1

2

Thanks to Hurelu in this post, who explains how shell commands are constructed using the definitions in tasks.json, I have been able to define a tasks file that can run both rspec and cucumber, using bundle's exec:

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

RSpec is the test command, so you can use Cmd+Shift+T/Ctrl+Shift+t to run the current file as an RSpec test.

Happy coding!

Community
  • 1
  • 1