Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the randomisation seed each run in Rspec with Guard/Spork?

I'm currently using Rspec for testing, along with Guard and Spork for convenience. I've noticed that unless I quit and restart Guard, the random seed does not change between runs. While this is not a major issue, it would be handy if it did.

Anyone know of a way to change things so that it does use a new seed each time it runs the tests??

like image 863
zkcro Avatar asked Jan 18 '13 05:01

zkcro


2 Answers

I added the --order rand:$RANDOM flag to my Guardfile:

guard 'rspec', zeus: true, cli: '--color --order rand:$RANDOM' do
  watch(...)
end
like image 152
RubeOnRails Avatar answered Oct 30 '22 09:10

RubeOnRails


Yes, the following works for me. Add to spec_helper.rb:

Spork.each_run do
  RSpec.configuration.seed = srand && srand % 0xFFFF
end

From here.

like image 2
valk Avatar answered Oct 30 '22 08:10

valk