Sha256: 86fdaad51fe2bf7255189273f637dbd8ec297cd83ac8edc7b5de0f307a3c2770

Contents?: true

Size: 584 Bytes

Versions: 6

Compression:

Stored size: 584 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Array do
  before do
    @array = [0,1,2,3,4,5,6,7,8,9]
  end

  it "should get a random item out of the array" do
    10.times { @array.should include(@array.random) }
  end

  it "should return nil if the array is empty" do
    [].random.should be_nil
  end

  it "should return a random subset of the array" do
    @array.random_subset(5).each do |i|
      @array.should include(i)
    end
  end

  it "should return a random subset of the array that is 3 long" do
    @array.random_subset(3).size.should == 3
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
sevenwire-forgery-0.1.0 spec/extensions/array_spec.rb
sevenwire-forgery-0.2.0 spec/extensions/array_spec.rb
sevenwire-forgery-0.2.1 spec/extensions/array_spec.rb
sevenwire-forgery-0.2.2 spec/extensions/array_spec.rb
forgery-0.3.0 spec/extensions/array_spec.rb
forgery-0.2.2 spec/extensions/array_spec.rb