Sha256: 5bf97ee92625a8f15e90da34f05ceabe3432c64aa9d6e474897047d5c9beb668
Contents?: true
Size: 1011 Bytes
Versions: 28
Compression:
Stored size: 1011 Bytes
Contents
# encoding: utf-8 require 'liquid/weighted_selector' describe WeightedSelector do describe "#empty?" do it do should be_empty end context do before do subject.add 'a', 0 end it do should_not be_empty end end end describe '#pick_one' do context do its(:pick_one){ should == nil } end context do before do subject.add 'a', 2 subject.add 'b', 2 subject.add 'c', 0 end it do ['a', 'b'].should include subject.pick_one end end context do before do subject.add 'a', 2 subject.add 'b', 2 subject.add 'c', 0 subject.delete 'a' end its(:pick_one){ should == 'b' } its(:pick_one_with_index){ should == ['b', 0] } end context do before do Kernel.stub(:rand).and_return(1.00) subject.add 'a', 0.1 end its(:pick_one){ should == 'a' } end end end
Version data entries
28 entries across 28 versions & 1 rubygems