2009-09-15 15:47:47 -04:00
|
|
|
ActiveRecord::Base.establish_connection(
|
|
|
|
:adapter => 'sqlite3',
|
|
|
|
:database => File.join(File.dirname(__FILE__), 'test.db')
|
|
|
|
)
|
|
|
|
|
|
|
|
class CreateSchema < ActiveRecord::Migration
|
|
|
|
def self.up
|
|
|
|
create_table :posts, :force => true do |t|
|
2009-09-15 16:56:20 -04:00
|
|
|
t.integer :author_id
|
2009-09-15 15:47:47 -04:00
|
|
|
t.string :title
|
|
|
|
t.string :body
|
|
|
|
end
|
2009-09-15 16:56:20 -04:00
|
|
|
|
|
|
|
create_table :users, :force => true do |t|
|
|
|
|
t.string :name
|
|
|
|
end
|
2009-09-15 15:47:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
CreateSchema.suppress_messages { CreateSchema.migrate(:up) }
|
|
|
|
|
2009-09-15 16:56:20 -04:00
|
|
|
class User < ActiveRecord::Base
|
|
|
|
end
|
|
|
|
|
2009-09-15 15:47:47 -04:00
|
|
|
class Post < ActiveRecord::Base
|
2009-09-15 16:56:20 -04:00
|
|
|
belongs_to :author, :class_name => 'User'
|
|
|
|
end
|
|
|
|
|
2009-09-15 17:58:23 -04:00
|
|
|
class NonActiveRecord
|
|
|
|
end
|
|
|
|
|
2009-09-15 16:56:20 -04:00
|
|
|
Factory.define :user do |f|
|
2009-09-15 15:47:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
Factory.define :post do |f|
|
2009-09-15 16:56:20 -04:00
|
|
|
f.association :author, :factory => :user
|
2009-09-15 15:47:47 -04:00
|
|
|
end
|
|
|
|
|
2009-09-15 17:58:23 -04:00
|
|
|
# This is here to ensure that factory step definitions don't raise for a non-AR factory
|
|
|
|
Factory.define :non_active_record do |f|
|
|
|
|
end
|
|
|
|
|
2009-09-15 15:47:47 -04:00
|
|
|
require 'factory_girl/step_definitions'
|