Skip to content

Instantly share code, notes, and snippets.

@pdg137
Created March 14, 2014 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdg137/9554958 to your computer and use it in GitHub Desktop.
Save pdg137/9554958 to your computer and use it in GitHub Desktop.
Random seeds in rspec contexts
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