Sha256: 0f848e4aaff9d5ab8cdae68945d64e33b80ba283d8ece58759edce08ad18bbef

Contents?: true

Size: 589 Bytes

Versions: 1

Compression:

Stored size: 589 Bytes

Contents

require 'spec_helper'

describe Array do
  before do
    @array = Forgery::Extend([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
    Forgery::Extend([]).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

1 entries across 1 versions & 1 rubygems

Version Path
forgery-0.6.0 spec/extensions/array_spec.rb