ismasan (owner)

Revisions

gist: 22227 Download_button fork
public
Public Clone URL: git://gist.github.com/22227.git
Text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Create ActiveRecord schemas on the fly for AR extensions testing
#
ActiveRecord::Base.establish_connection(
  :adapter=>'sqlite3',
  :dbfile=> File.join(File.dirname(__FILE__),'..','spec','db','test.db')
)
# define a migration
class TestSchema < ActiveRecord::Migration
  def self.up
    create_table :items do |t|
      t.string :title
      t.string :slug
      t.string :permalink
      t.boolean :published
      t.integer :category_id
      t.timestamps
    end
  end
 
  def self.down
    drop_table :items
  end
end
 
 
namespace :db do
  desc "Create test schema"
  task :create => :destroy do
    # run the migration
    TestSchema.migrate(:up)
  end
  
  desc "Destroy test schema"
  task :destroy do
    TestSchema.migrate(:down)
  end
end