File: sample_spec.rb

package info (click to toggle)
ruby-hamster 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,932 kB
  • sloc: ruby: 16,915; makefile: 4
file content (14 lines) | stat: -rw-r--r-- 402 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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