-
|
When I run a test in the VSCode extension it's executed using the absolute path. Our tests run in a Docker container due to our setup, so this results in the following error: Is there a way to run the spec using a relative path so that it works with the Docker container? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Did you already try to configure VS Code to connect to the container (docs)? |
Beta Was this translation helpful? Give feedback.
-
|
I do not want to be annoying, but that's another problem with dockerized env, that can be addressed by proposed solution: #2919 |
Beta Was this translation helpful? Give feedback.
-
|
Workaround with a wrapper script: Create #!/bin/bash
# Get the absolute path from the argument
ABS_PATH="$1"
# Get the current working directory
CURRENT_DIR="$PWD"
# Remove the current directory prefix from the absolute path
REL_PATH="${ABS_PATH#"$CURRENT_DIR"/}"
# Run the command with the relative path
bin/rspec "$REL_PATH"Then in your "rubyLsp.addonSettings": {
"Ruby LSP Rails": {
"rspecCommand": "./rspec_wrapper"
}
},Adjust the docker exec -t my-container bin/rspec "$REL_PATH" |
Beta Was this translation helpful? Give feedback.
Workaround with a wrapper script:
Create
rspec_wrapperand thenchmod +x rspec_wrapper:Then in your
settings.json:Adjust the
rspec_wrapperscript to your liking. For example, to pass the path to some docker container: