This repository was archived by the owner on Jan 10, 2024. It is now read-only.
Fix spec_dir lookup when Dir.pwd is not Rails.root #227
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
I was able to get this gem to work with my engine by going
inside the
test_appdir and runningbundle exec rails spec:javascriptSo far so good. The problem is that I don't want to have to run
cd spec/test_appevery time to run my Javascript tests. I want to run themfrom the engine's grandparent directory so I can include it in my Rakefile for
the entire test suite. In other words, this is my dir tree:
Rails.rootis always~/engine/spec/test_app/, regardless of whetherI'm in `~/engine/ or not.
The problem
Look at this line:
Dir.glob path, equivalent toDir.glob("spec/javascripts")returnstruebecauseDir.pwdis~/engine/, therefore~/engine/spec/javascriptsexists.However, the last
collecthasRails.root.join("spec_javascript),which will map to
~/engine/spec/test_app/spec/javascripts, butthere's nothing there (because my test files were configured to
~/engine/spec/javascript).To "fix that, I put
../javascriptsin my yml'sspec_dir, but noDir.globjust returns false because, in fact,
~/engine/../javascriptsdoesn't exist.So, the code is verifying one path and resolving to some other.
The fix
This fix just makes it cohesive.
I suspect this is in a way connected with
#102 (to make it work with
engines).