Sha256: d488e51ef44842452b1460de1393aabffe2ec42bb1abbbe0db818bc14efa9a78

Contents?: true

Size: 402 Bytes

Versions: 5

Compression:

Stored size: 402 Bytes

Contents

require "spec_helper"
require "hamster/hash"

describe Hamster::Hash do
  describe "#sample" do
    let(:hash) { Hamster::Hash.new((:a..:z).zip(1..26)) }

    it "returns a randomly chosen item" do
      chosen = 250.times.map { hash.sample }.sort.uniq
      chosen.each { |item| hash.include?(item[0]).should == true }
      hash.each { |item| chosen.include?(item).should == true }
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/hamster-3.0.0/spec/lib/hamster/hash/sample_spec.rb
hamster-3.0.0 spec/lib/hamster/hash/sample_spec.rb
hamster-2.0.0 spec/lib/hamster/hash/sample_spec.rb
hamster-1.0.0 spec/lib/hamster/hash/sample_spec.rb
hamster-1.0.1.pre.rc3 spec/lib/hamster/hash/sample_spec.rb