Sha256: 6d7df1fd416eaed3a36ed13c105b1b9437cf0475645cb41601156a6a2af329dc
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
require 'rspec/core' # require 'autotest/rspec2' require 'rails' require 'active_record' require 'arel' require 'meta_where' require 'yaml' require 'logger' require 'database_cleaner' require 'roles_active_record' module Rails def self.config_root_dir File.dirname(__FILE__) end end SPEC_DIR = File.dirname(__FILE__) path = SPEC_DIR + '/db/database.yml' dbfile = File.open(path) dbconfig = YAML::load(dbfile) ActiveRecord::Base.establish_connection(dbconfig) ActiveRecord::Base.logger = Logger.new(STDERR) # Attempts at trying to make database_cleaner accept another location for database.yml # ------------------------------------------------------------------------------------ module ActiveRecord def self.config_file_location File.dirname(__FILE__) + '/db/database.yml' end end module DatabaseCleaner module ActiveRecord def self.config_file_location "#{DatabaseCleaner.app_root}/spec/db/database.yml" end end end DatabaseCleaner.strategy = :truncation def api_fixture end # $ rake VERSION=0 def migration_folder(name) path = File.dirname(__FILE__) + "/migrations/#{name}" end ORM_NAME = 'Active Record' def migrate(name) mig_folder = migration_folder(name) puts "Migrating folder: #{mig_folder}" ActiveRecord::Migrator.migrate mig_folder end RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) # DatabaseCleaner.clean end config.before(:each) do DatabaseCleaner.start migrate('users') api_migrate end config.after(:each) do DatabaseCleaner.clean end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
roles_active_record-0.4.9 | spec/spec_helper.rb |
roles_active_record-0.4.8 | spec/spec_helper.rb |
roles_active_record-0.4.7 | spec/spec_helper.rb |