-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support running tests in Rails engines #1274
Conversation
1db5ebe
to
889f2c0
Compare
@tristil have you tried installing the |
@st0012 I tried it out and it didn't work. When running engine tests manually we always cd into the engine directory. |
Can you explain how it didn't work? Was the |
@st0012 I run |
Some context is that we are a big company with a Rails monolith that is divided into 40+ engines. So although it's true that we could open vscode, etc. in each engine it would be a lot of context switching especially since there are interactions between engines and the top level app. |
To run a test in a Rails engine you need to cd into the engine before running the test.
When we add commands for changing the cwd to the test command passed to rdbg we need to start shell escaping the command.
889f2c0
to
e49c57d
Compare
Sorry about the lack of feedback. The main issue with this is solving it in a general way that works for any app using engines. My understanding is that you don't have to put the engines under the Also, depending on your Gemfile setup, then the files in engines are available for require from the top level, avoiding this issue. If you discover that there is a convention about how to run tests inside engines and where to put them or if you find an alternative that works generally, please let us know. |
@vinistock Sorry, I should have left a comment about why I was closing. Basically I think this is too specific to my organization's needs, plus we are moving away from engines to Packwerk packs. But: the underlying problem is that |
Motivation
In Rails projects with engines, you need to cd into the engine in order to run a test, or else requires, etc. will not work.
Implementation
This change detects when a file has
engines
in its path and has a Rails dependency and alters the command to cd in (and out, afterwards) of the engine. This allows running a test and sending the test to terminal. The special characters involved break debug, which is fixed in the second commit. The second commit escapes the command when passing tordbg
.Automated Tests
Tests added
Manual Tests
I am able to run tests in an engine using VS Code