Class: Birdbath::Schema

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

Instance Method Summary collapse

Methods included from Connection

#conn

Constructor Details

#initializeSchema

:nodoc:



106
107
108
# File 'lib/birdbath.rb', line 106

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

Instance Method Details

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

Yields:



110
111
112
113
114
115
# File 'lib/birdbath.rb', line 110

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

#verifyObject

:nodoc:



117
118
119
120
121
# File 'lib/birdbath.rb', line 117

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