Sha256: 3d5dd229b6d7300bb1163c55b00f48b7d5ada9289e1a54175587141f6a9f5383

Contents?: true

Size: 1.33 KB

Versions: 11

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

module RailsBestPractices
  module Prepares
    describe SchemaPrepare do
      let(:runner) { Core::Runner.new(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 = Prepares.model_attributes
        expect(model_attributes.get_attribute_type("Post", "title")).to eq("string")
        expect(model_attributes.get_attribute_type("Post", "body")).to eq("text")
        expect(model_attributes.get_attribute_type("Post", "created_at")).to eq("datetime")
        expect(model_attributes.get_attribute_type("Post", "user_id")).to eq("integer")
        expect(model_attributes.get_attribute_type("Post", "comments_count")).to eq("integer")
        expect(model_attributes.get_attribute_type("Post", "published")).to eq("boolean")
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rails_best_practices-1.19.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.18.1 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.18.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.17.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.16.0 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.15.7 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.15.6 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.15.4 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.15.3 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.15.2 spec/rails_best_practices/prepares/schema_prepare_spec.rb
rails_best_practices-1.15.1 spec/rails_best_practices/prepares/schema_prepare_spec.rb