-
Notifications
You must be signed in to change notification settings - Fork 285
5. Example configurations
These examples are designed to show how to use the debugger setup in common situations. They can be used as a baseline for debugging your own scripts.
Each of these code blocks would be placed inside the configurations
array of the launch.json
file structured as:
{
"version": "0.2.0",
"configurations": []
}
These examples have deliberately varying path structure, so you may have to mix and match to get something that's good for your system.
This will run the rails server at the workspace root. It assumes that the binstubs have been installed with bundler install --binstubs
.
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rails",
"args": ["server"]
}
This will run the a rake task.
It assumes ruby-debug-ide was installed with bundle and runs it with bundler exec
.
It also assumes bundler is available in your PATH.
{
"name": "Rake db:migrate",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/vendor/rake",
"useBundler": true,
"args": ["db:migrate"]
}
This will run all of the specs with some extra settings passed.
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "/usr/bin/rspec",
"args": [
"--require", "spec_helper",
"--require", "rails_helper",
"--format", "documentation"
]
}
This will run RSpec, but only on the currently open spec file. If the current file isn't a spec file, RSpec will fail with 'no specs found' or some such error.
{
"name": "RSpec - open spec file",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rspec",
"args": ["${file}"]
}
Run all your cukes.
{
"name": "Cucumber",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/cucumber"
}
Run Test::Unit only on the currently open test file. Include additional paths in the $LOAD_PATH with the includes
config option.
{
"name": "Test::Unit - open test file",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${file}",
"includes": ["test", "lib"]
}
Run Test::Unit for a single selected test, only on the currently open test file.
{
"name": "Test::Unit - single selected test",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${file}",
"includes": ["test", "lib"],
"args": [
"-n",
"${selectedText}"
]
}
Setup
- Debugger Installation
- Launch from VS Code
- Attach to a debugger
- Running Gem scripts
- Example configuration
How to contribute