Sha256: acd76839f5bbdc61c8f48490c46067f64d4f7f266cf26b9545ea082a4b0c8049

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe RailsBestPractices::Prepares::SchemaPrepare do
  let(:runner) { RailsBestPractices::Core::Runner.new(:prepares => RailsBestPractices::Prepares::SchemaPrepare.new) }

  it "should parse model attributes" do
    content =<<-EOF
    ActiveRecord::Schema.define(:version => 20110319172136) do
      create_table "posts", :force => true do |t|
        t.string   "title"
        t.text     "body",           :limit => 16777215
        t.datetime "created_at"
        t.integer  "user_id"
        t.integer  "comments_count",                     :default => 0
        t.boolean  "published",                          :default => false, :null => false
      end
    end
    EOF
    runner.prepare("db/schema.rb", content)
    model_attributes = RailsBestPractices::Prepares.model_attributes
    model_attributes.get_attribute_type("Post", "title").should == "string"
    model_attributes.get_attribute_type("Post", "body").should == "text"
    model_attributes.get_attribute_type("Post", "created_at").should == "datetime"
    model_attributes.get_attribute_type("Post", "user_id").should == "integer"
    model_attributes.get_attribute_type("Post", "comments_count").should == "integer"
    model_attributes.get_attribute_type("Post", "published").should == "boolean"
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
rails_best_practices-gorgeouscode-1.0.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.9.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.8.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.7.2 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.7.1 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.7.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.6.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.5.3 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.5.2 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.5.1 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.5.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.4.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.3.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.2.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.1.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.0.1 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.0.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb