spring: Spring causes rspec to always order tests the same
When running rspec with config.order = "random"
spring causes the order to always be the same.
[master●●] % spring rspec
....
Finished in 0.21176 seconds
4 examples, 0 failures
Randomized with seed 6661
[master●●] % spring rspec
....
Finished in 0.21373 seconds
4 examples, 0 failures
Randomized with seed 6661
[master●●] % spring rspec
....
Finished in 0.16834 seconds
4 examples, 0 failures
Randomized with seed 6661
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 25 (8 by maintainers)
Commits related to this issue
- Stop preloading spec_helper and test_helper by default This causes subtle issues, such as #113. I did this because I find it useful to preload my spec_helper in the project I work on (because it is ... — committed to rails/spring by jonleighton 11 years ago
- Ensure tests run in a random order each time I recently noticed that my tests were always using the same seed, instead of running in a different order each time, as per the RSpec configuration. This... — committed to UKGovernmentBEIS/beis-report-official-development-assistance by leeky 4 years ago
I’ve noticed the same issue today. Since its tied to
spring
I didn’t want to include it directly inspec_helper
so I ended up combining @jcarlson’s solution and @mwean’s solution into one in theconfig/spring.rb
file:This way it’s only done if someone is running
bin/rspec
but still supports overriding the seed through the command line parameter. Thanks!For what it’s worth, this is what I’m doing now in my
spec_helper.rb
:This still gives me the ability to override the seed like I’m used to.
Thanks to everyone in this thread for the above collaboration, and especially to @javierjulio for putting it all together so elegantly.
Just ran into this on spring@2.0.2, rspec@3.7.0. Don’t understand why this is marked as closed. Thankfully the workaround above still works.
Seems like it should just work out of the box. Where would the fix go though? In
spring
? Inspring-commands-rspec
?Thanks @mwean, your workaround works perfectly! @jonleighton This issue should probably be reopened.
This still seems to be an issue [spring@1.6.3, rspec@3.4.0] but the suggestion of @mwean works 😄
Just upgraded to 0.0.10, and I still need this block in
config/spring.rb
:I’m willing to agree that RSpec might be partly at fault here, but even after doing some debugging, I’m kind of at a loss to understand why RSpec gives itself a default seed of
0
with Spring and a random seed without.Any other thoughts?