Sha256: 265cb7b788d566ef8e867921a27823e4259c1c61aff96e77de14847051876cc4

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require File.dirname(__FILE__) + "/spec_helper"

describe 'Single Table Inheritance' do
  
  before(:all) do
    fixtures(:people)
  end
  
  it "should save and load the correct Type" do
    database do
      ted = SalesPerson.new(:name => 'Ted')
      ted.save
    
      clone = Person.first(:name => 'Ted')
      ted.should == clone
      
      clone.class.should eql(SalesPerson)      
    end
    
    # Since we're not executing within the same database context
    # this is not the same object instance as the previous ones.
    clone2 = Person.first(:name => 'Ted')
    
    clone2.class.should eql(SalesPerson)    
  end
  
  it "secondary database should inherit the same attributes" do
    
    database(:mock) do |db|
      db.table(SalesPerson)[:name].should_not be_nil
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datamapper-0.2.4 spec/single_table_inheritance_spec.rb