Class: Spec::Example::MigrationExampleGroup

Inherits:
ExampleGroup
  • Object
show all
Includes:
Matchers::Migration
Defined in:
lib/spec/example/migration_example_group.rb

Instance Method Summary (collapse)

Methods included from Matchers::Migration

#be_primary_key, #have_column, #have_table, #permit_null

Instance Method Details

- (Object) all_databases



53
54
55
# File 'lib/spec/example/migration_example_group.rb', line 53

def all_databases
  @@migrations.map { |m| m.database }.uniq
end

- (Object) migration_name



49
50
51
# File 'lib/spec/example/migration_example_group.rb', line 49

def migration_name
  @migration_name ||= self.class.instance_variable_get("@description_text").to_s
end

- (Object) run_migration



45
46
47
# File 'lib/spec/example/migration_example_group.rb', line 45

def run_migration
  this_migration.perform_up
end

- (Object) run_prereq_migrations



34
35
36
37
38
39
40
41
42
43
# File 'lib/spec/example/migration_example_group.rb', line 34

def run_prereq_migrations
  "running n-1 migrations"
  all_databases.each do |db|
    db.adapter.recreate_database
  end
  @@migrations.sort.each do |migration|
    break if migration.name.to_s == migration_name.to_s
    migration.perform_up
  end
end

- (Object) select(sql)



61
62
63
# File 'lib/spec/example/migration_example_group.rb', line 61

def select(sql)
  this_migration.adapter.select(sql)
end

- (Object) table(table_name)



65
66
67
# File 'lib/spec/example/migration_example_group.rb', line 65

def table(table_name)
  this_migration.adapter.table(table_name)
end

- (Object) this_migration



57
58
59
# File 'lib/spec/example/migration_example_group.rb', line 57

def this_migration
  @@migrations.select { |m| m.name.to_s == migration_name }.first
end