Sha256: 3064ea9b902747f19589959666d36c6f50df662b186307c3c535720b03265683

Contents?: true

Size: 606 Bytes

Versions: 2

Compression:

Stored size: 606 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 { expect(@array).to include(@array.random) }
  end

  it "should return nil if the array is empty" do
    expect(Forgery::Extend([]).random).to be_nil
  end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forgery-0.8.1 spec/extensions/array_spec.rb
forgery-0.7.0 spec/extensions/array_spec.rb