Sha256: 4d0c180395ba8963660fd5f5cd197635ab1b51bb4fed7a15c1ba18ca9ae6a2a7

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

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

describe DataMapper::Adapters::Sql::Mappings::Table do
  it "should return all columns from the database" do
    table = database.adapter.schema.database_tables.detect{|table| table.name == "zoos"}
    columns = table.database_columns
    columns.size.should == database.schema[Zoo].columns.size
    columns.each { |column| column.should be_a_kind_of( DataMapper::Adapters::Sql::Mappings::Column ) }
  end
  
  it "should return the default for a column from the database" do
    table = database.adapter.schema.database_tables.detect{|table| table.name == "animals"}
    columns = table.database_columns
    
    column1 = columns.detect{|column| column.name == :name }
    column1.default.should == "No Name"
    
    column2 = columns.detect{|column| column.name == :nice }
    column2.default.should == nil
  end
  
  it "should return the nullability for a column from the database" do
    table = database.adapter.schema.database_tables.detect{|table| table.name == "animals"}
    columns = table.database_columns
    
    column1 = columns.detect{|column| column.name == :id }
    column1.nullable?.should be_false
    
    column2 = columns.detect{|column| column.name == :nice }
    column2.nullable?.should be_true
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datamapper-0.2.4 spec/table_spec.rb