Sha256: 7ede9f2c19be978751c0a59da486b75969bb8ceaac1a062ba42c32f9e9524be8

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

context 'An Exhibit' do
  
  setup do
    @aviary = Exhibit[:name => 'Monkey Mayhem']
  end
  
  specify 'has a zoo association' do
    @aviary.zoo.class.should == Zoo
    Exhibit.new.zoo.should == nil
  end
  
  specify 'belongs to a zoo' do
    database do |db|
      @aviary.zoo.should == @aviary.session.first(Zoo, :name => 'San Diego')
    end
  end
  
  specify 'can build its zoo' do
    database do |db|
      e = Exhibit.new({:name => 'Super Extra Crazy Monkey Cage'})
      e.zoo.should == nil
      e.build_zoo({:name => 'Monkey Zoo'})
      e.zoo.class == Zoo
      e.zoo.new_record?.should == true
      
      # Need to get associations working properly before this works ....
      e.save
    end
  end
  
  specify 'can build its zoo' do
    database do |db|
      e = Exhibit.new({:name => 'Super Extra Crazy Monkey Cage'})
      e.zoo.should == nil
      e.create_zoo({:name => 'Monkey Zoo'})
      e.zoo.class == Zoo
      e.zoo.new_record?.should == false
      e.save
    end
  end
  
  teardown do
    fixtures('zoos')
    fixtures('exhibits')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datamapper-0.1.1 spec/belongs_to.rb