This repository has been 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_app
dir and runningbundle exec rails spec:javascript
So far so good. The problem is that I don't want to have to run
cd spec/test_app
every 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.root
is 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")
returnstrue
becauseDir.pwd
is~/engine/
, therefore~/engine/spec/javascripts
exists.However, the last
collect
hasRails.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
../javascripts
in my yml'sspec_dir
, but noDir.glob
just returns false because, in fact,
~/engine/../javascripts
doesn'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).