Sha256: c8df07d6815711a05b12a3c198900817372badd87a93f1311186595d0f4ac873

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'
require 'annotate/annotate_models'

describe AnnotateModels do

  def mock_klass(stubs={})
    @mock_file ||= mock("Klass", stubs)
  end

  def mock_column(stubs={})
    @mock_column ||= mock("Column", stubs)
  end

  it { AnnotateModels.quote(nil).should eql("NULL") }
  it { AnnotateModels.quote(true).should eql("TRUE") }
  it { AnnotateModels.quote(false).should eql("FALSE") }
  it { AnnotateModels.quote(25).should eql("25") }
  it { AnnotateModels.quote(25.6).should eql("25.6") }
  it { AnnotateModels.quote(1e-20).should eql("1.0e-20") }

  it "should get schema info" do

    AnnotateModels.get_schema_info(mock_klass(
      :table_name => "users",
      :primary_key => "id",
      :column_names => ["id","login"],
      :columns => [
        mock_column(:type => "integer", :default => nil, :null => false, :name => "id", :limit => nil),
        mock_column(:type => "string", :default => nil, :null => false, :name => "name", :limit => 50)
      ]), "Schema Info").should eql(<<-EOS)
# Schema Info
#
# Table name: users
#
#  id    :integer         not null, primary key
#  id    :integer         not null, primary key
#

EOS

  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
codeape-annotate-2.0.0.20090212001 spec/annotate/annotate_models_spec.rb
nofxx-annotate-2.3.0 spec/annotate/annotate_models_spec.rb
nofxx-annotate-2.3.1 spec/annotate/annotate_models_spec.rb