Sha256: 3ced5f511ab9e2e6527839bdd4b2588813cdcbe8cc977a36981e1557da559430

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 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.find(Exhibit, :first, :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.0 spec/has_many.rb