In the extensions marketplace, search "ruby-debug" and install globally. You may need to reload your workspace afterwards.
You'll need to add readapt to your project's gemfile and bundle install.
group :development do
# gems...
gem 'readapt' # Debugging with vscode ruby-debug extension
# gems...
end
Then add the appropriate configuration either to your global settings.json:
{
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "ruby-debug",
"request": "launch",
"name": "Ruby",
"program": "${file}",
"programArgs": [],
"useBundler": false
},
{
"type": "ruby-debug",
"request": "launch",
"name": "RSpec LocalFile",
"program": "rspec",
"programArgs": ["${relativeFile}"],
"useBundler": true
},
{
"type": "ruby-debug",
"request": "launch",
"name": "RSpec Selected Line",
"program": "rspec",
"programArgs": ["${relativeFile}:${lineNumber}"],
"useBundler": true
}
]
}
or your workspace/.vscode/launch.json file
{
"version": "0.2.0",
"configurations": [
{
"type": "ruby-debug",
"request": "launch",
"name": "Ruby",
"program": "${file}",
"programArgs": [],
"useBundler": false
},
{
"type": "ruby-debug",
"request": "launch",
"name": "RSpec LocalFile",
"program": "rspec",
"programArgs": ["${relativeFile}"],
"useBundler": true
},
{
"type": "ruby-debug",
"request": "launch",
"name": "RSpec Selected Line",
"program": "rspec",
"programArgs": ["${relativeFile}:${lineNumber}"],
"useBundler": true
}
]
}
Open an rspec test or plain ol ruby file, and go to the debug tab. Select the option you want to run when you press F5.
Put a breakpoint in your rspec file and press F5 or click the green arrow shown above to run the test.
Use the debug window at the bottom of your window to debug!