Skip to content
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

Spring does not preserve Rails root as current directory thus making impossible to run tests from a subfolder #641

Open
mlt opened this issue Jan 23, 2021 · 2 comments

Comments

@mlt
Copy link

mlt commented Jan 23, 2021

For some reason Spring sets working folder to that from where the command was launched instead of keeping it as RAILS_ROOT. It looks like Rails testing framework expects it that way and thus gets broken. Steps to reproduce with Rails 6.1.1:

rails new spring_test
cd spring_test
bundle exec rails generate scaffold Model name:text
bundle exec rails db:migrate
bundle exec rails test

All is good and we see something like

Running via Spring preloader in process 3209
/home/mlt/.rvm/gems/ruby-2.6.6/gems/spring-2.1.1/lib/spring/application.rb:204: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Run options: --seed 25091
# Running:
.......
Finished in 0.714637s, 9.7952 runs/s, 12.5938 assertions/s.
7 runs, 9 assertions, 0 failures, 0 errors, 0 skips

Now let's move to some project subfolder

cd db
bundle exec rails test

No tests are found because they are being looked for at the wrong place, i.e. db/test/**/*_test.rb.

Running via Spring preloader in process 3381
/home/mlt/.rvm/gems/ruby-2.6.6/gems/spring-2.1.1/lib/spring/application.rb:204: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Run options: --seed 47427

# Running:

Finished in 0.000600s, 0.0000 runs/s, 0.0000 assertions/s.

Everything gets back to normal once we disable Spring:

[mlt@host db]$ DISABLE_SPRING=1 bundle exec rails test
Run options: --seed 7928
# Running:
.......
Finished in 0.714637s, 9.7952 runs/s, 12.5938 assertions/s.
7 runs, 9 assertions, 0 failures, 0 errors, 0 skips
@deivid-rodriguez
Copy link
Contributor

Can you repro on spring 2.1.0? If you can't, it's likely that it's a regression on 2.1.0 that was reverted, but the revert is not yet released.

@mlt
Copy link
Author

mlt commented Jan 24, 2021

Regression it is! With 2.1.0:

[mlt@host db]$ bundle exec rails test
Running via Spring preloader in process 4037
/home/mlt/.rvm/gems/ruby-2.6.6/gems/spring-2.1.0/lib/spring/application.rb:199: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Run options: --seed 44870
# Running:
.......
Finished in 18.512508s, 0.3781 runs/s, 0.4862 assertions/s.
7 runs, 9 assertions, 0 failures, 0 errors, 0 skips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants