Created
March 14, 2014 19:26
-
-
Save pdg137/9554958 to your computer and use it in GitHub Desktop.
Random seeds in rspec contexts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Random do | |
specify do | |
puts "Random seed was #{Random.srand}" | |
end | |
specify do | |
puts "Random seed was #{Random.srand}" | |
end | |
context "A" do | |
specify do | |
puts "Random seed was #{Random.srand}" | |
end | |
end | |
context "B" do | |
specify do | |
puts "Random seed was #{Random.srand}" | |
end | |
end | |
end | |
# $ rspec spec/features/test_spec.rb --seed 123 -f d | |
# | |
# Random | |
# Random seed was 123 | |
# example at ./spec/features/test_spec.rb:2 | |
# Random seed was 23052841652209183563764026608716621481 | |
# example at ./spec/features/test_spec.rb:6 | |
# A | |
# Random seed was 123 | |
# example at ./spec/features/test_spec.rb:11 | |
# B | |
# Random seed was 123 | |
# example at ./spec/features/test_spec.rb:17 | |
# | |
# Finished in 0.01151 seconds | |
# 4 examples, 0 failures | |
# | |
# Randomized with seed 123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment