Sha256: 2e3e25604c9395ac7b9b1768c2b78daca952cdf630ea2d242485c1ae70ecd87b

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../require")
Require.spec_helper!

Spec::Runner.configure do |config|
end

$db, $log = ActiveWrapper.setup(
  :base => File.dirname(__FILE__),
  :env => 'test'
)
$db.establish_connection

def record_match?(original, copy)
  (original.class.column_names & copy.class.column_names).each do |col|
    copy.send(col).should == original.send(col)
  end
end

def columns(table)
  connection.columns(table).collect(&:name)
end

def connection
  ActiveRecord::Base.connection
end

def create_records(klass=Article, values={})
  klass.delete_all
  (1..5).collect do |x|
    klass.column_names.each do |column|
      if column == 'article_id'
        values[:article_id] = x
      else
        values[column.intern] = "#{klass} #{x} #{column}"
      end
    end
    values[:id] = x
    klass.create(values)
  end
end

def migrate_with_state(version)
  @old_article_columns = columns("articles")
  @old_archive_columns = columns("articles_archive")
  $db.migrate(version)
  @new_article_columns = columns("articles")
  @new_archive_columns = columns("articles_archive")
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mover-0.1.1 spec/spec_helper.rb