grosser / single_cov

Actionable code coverage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring compatibility?

swrobel opened this issue · comments

Seeing a lot of app/models/user.rb was expected to be covered, but never loaded. and similar when running tests with spring. Running them with bundle exec doesn't exhibit this behavior.

Is the user loaded during the test run ? (add a puts "NOW" into user.rb to find out)
... if yes then that should be easy to fix.

... if no then we need to do coverage merging like forking_test_runner does it see https://github.com/grosser/forking_test_runner/blob/master/lib/forking_test_runner.rb#L7

Could also make a PR so that it detects if spring is running and say "Was already loaded, run this test without spring" ... not sure if that's reliable or helpful though ...

Otherwise make a PR to add a spring helper that does the merge-coverage thing from forking-test-runner ... maybe then put that here into the gem ... not sure how reliable/helpful that will be though

Interesting...

$ spring status
Spring is not running.

  ~/Code/boost [dev] [2.5.0]
$ rspec spec/models/user_spec.rb 
LOADED
Running via Spring preloader in process 5619
.....*

Finished in 1.92 seconds (files took 0.70206 seconds to load)
6 examples, 0 failures, 1 pending

app/models/user.rb was expected to be covered, but never loaded.

$ rspec spec/models/user_spec.rb
Running via Spring preloader in process 5719
.....*

Finished in 0.94107 seconds (files took 0.28501 seconds to load)
6 examples, 0 failures, 1 pending

app/models/user.rb was expected to be covered, but never loaded.

$ bundle exec rspec spec/models/user_spec.rb
LOADED
.....*

Finished in 0.72048 seconds (files took 2.54 seconds to load)
6 examples, 0 failures, 1 pending

spring loads the app first, then starts the test ... to make this work coverage reporting needs to be started when spring starts ... and then merged ...
could always start coverage recording when spring starts in test env ...

Another strong sign that it's probably time for me to give up on spring. Thanks for the suggestions!