Sha256: 0fe5015e4bc027277b2ecb0b039d5661f64a68b875b31dff54e94cdec692f413
Contents?: true
Size: 988 Bytes
Versions: 10
Compression:
Stored size: 988 Bytes
Contents
require 'spec_helper' require 'dm-migrations/auto_migration' describe DataMapper::Migrations do def capture_log(mod) original, mod.logger = mod.logger, DataObjects::Logger.new(@log = StringIO.new, :debug) yield ensure @log.rewind @output = @log.readlines.map do |line| line.chomp.gsub(/\A.+?~ \(\d+\.?\d*\)\s+/, '') end mod.logger = original end supported_by :postgres do before :all do module ::Blog class Article include DataMapper::Resource property :id, Serial end end @model = ::Blog::Article end describe '#auto_upgrade' do it 'should create an index' do @model.auto_migrate! @property = @model.property(:name, String, :index => true) @response = capture_log(DataObjects::Postgres) { @model.auto_upgrade! } @output[-2].should == "CREATE INDEX \"index_blog_articles_name\" ON \"blog_articles\" (\"name\")" end end end end
Version data entries
10 entries across 10 versions & 2 rubygems