Sha256: e011d7d22e0a4d3bcc6c9a748138eeda83a17285d11c70b7d4e713be4c1ba7aa
Contents?: true
Size: 967 Bytes
Versions: 10
Compression:
Stored size: 967 Bytes
Contents
require 'spec_helper' module RSpec module Core RSpec.describe RandomNumberGenerator do it 'is a random number generator' do random = described_class.new expect([Fixnum, Bignum]).to include random.seed.class expect(random.rand).to be_a Float rands = [] 100.times do rands << random.rand end expect(rands.uniq.count).to be > 90 end it 'produces the same results given the same seed' do seed = rand(999) random = described_class.new(seed) expect(random.seed).to eq seed expected = [] 5.times do expected << random.rand(999) end 10.times do random = described_class.new(seed) expect(random.seed).to eq seed actual = [] 5.times do actual << random.rand(999) end expect(actual).to eq expected end end end end end
Version data entries
10 entries across 10 versions & 3 rubygems