Sha256: 70a0416f0a892c138c820055294854a471005507451dbd4c00c42c28ad102a93

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

describe DataMapper::Associations::HasManyAssociation do
  
  before(:all) do
    fixtures(:zoos)
    fixtures(:exhibits)
    
    @san_diego = Zoo[:name => 'San Diego']
    @dallas = Zoo[:name => 'Dallas']
    @miami = Zoo[:name => 'Miami']
  end
    
  it 'should expose a proxy for the accessor' do
    [@miami, Zoo.new].each do |z|
      z.exhibits.class.should == DataMapper::Associations::HasManyAssociation
    end
  end
  
  it 'should lazily-load the association when Enumerable methods are called' do
    database do |db|
      @san_diego.exhibits.size.should == 2
      @san_diego.exhibits.should include(@san_diego.session.first(Exhibit, :name => 'Monkey Mayhem'))
    end
  end
  
  it 'should eager-load associations for an entire set' do
    zoos = Zoo.all
    zoos.each do |zoo|
      zoo.exhibits.each do |exhibit|
        exhibit.zoo.should == zoo
      end
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datamapper-0.1.1 spec/has_many.rb