Class: MigrationTestHelper::Schema

Inherits:
Object
  • Object
show all
Includes:
Connection, Test::Unit::Assertions
Defined in:
lib/migration_test_helper.rb

Instance Method Summary collapse

Methods included from Connection

#conn

Constructor Details

#initializeSchema

:nodoc:



105
106
107
# File 'lib/migration_test_helper.rb', line 105

def initialize #:nodoc:
  @tables = []
end

Instance Method Details

#table(name) {|table| ... } ⇒ Object

Yields:



109
110
111
112
113
114
# File 'lib/migration_test_helper.rb', line 109

def table(name)
  table = Table.new(name)
  yield table
  table.verify
  @tables << table
end

#verifyObject

:nodoc:



116
117
118
119
120
# File 'lib/migration_test_helper.rb', line 116

def verify #:nodoc:
  actual_tables = conn.tables.reject {|t| t == 'schema_info' || t == 'schema_migrations' }
  expected_tables = @tables.map {|t| t.name }
  assert_equal expected_tables.sort, actual_tables.sort, 'wrong tables in schema'
end