Skip to content

Is there a way to use relative paths for the Test Runner? #2965

Closed Answered by pprotas
pprotas asked this question in Q&A
Discussion options

You must be logged in to vote

Workaround with a wrapper script:

Create rspec_wrapper and then chmod +x rspec_wrapper:

#!/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 settings.json:

"rubyLsp.addonSettings": {
  "Ruby LSP Rails": {
    "rspecCommand": "./rspec_wrapper"
  }
},

Adjust the rspec_wrapper script to your liking. For example, to pass the path to some docker container:

docker exec -t my-container bin/rspec "$REL_PATH"

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by pprotas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants