require'spec_helper'# Check consistency of db/schema.rb version, migrations' timestamps, and the latest migration timestamp# stored in the database's schema_migrations table.describeActiveRecord::Schemadolet(:latest_migration_timestamp)do
migrations.map{|migration|File.basename(migration).split('_').first.to_i}.maxendit'> schema version equals last migration timestamp'dodefined_schema_version=File.open(Rails.root.join('db','schema.rb'))do|file|file.find{|line|line=~/ActiveRecord::Schema.define/}end.match(/(\d+)/)[0].to_iexpect(defined_schema_version).toeq(latest_migration_timestamp)endit'> schema version should equal the latest migration timestamp stored in schema_migrations table'doexpect(latest_migration_timestamp).toeq(ActiveRecord::Migrator.current_version.to_i)endend