module RSpec::StickySeed

Constants

VERSION

Public Class Methods

any_failures?() click to toggle source
# File lib/rspec/sticky_seed/write_seed.rb, line 3
def self.any_failures?
  examples = RSpec.world.filtered_examples.values.flatten
  examples.any?(&:exception)
end
read_seed() click to toggle source
# File lib/rspec/sticky_seed/read_seed.rb, line 3
def self.read_seed
  seed = File.read(".rspec-seed").to_i rescue 0
  RSpec.configuration.seed = seed
  srand seed+1
end
write_seed() click to toggle source
# File lib/rspec/sticky_seed/write_seed.rb, line 8
def self.write_seed
  return if any_failures?
  File.write(".rspec-seed","#{RSpec.configuration.seed+1}\n")
end