Permalink
Browse files

added spec_helper

  • Loading branch information...
1 parent da20366 commit 3fbf69fe8aa111e6dd1a77b3c26b7318431c57f4 @kristianmandrup committed Aug 12, 2012
Showing with 36 additions and 0 deletions.
  1. +1 −0 lib/cantango-cache.rb
  2. +35 −0 spec/spec_helper.rb
View
@@ -1,3 +1,4 @@
+require 'cantango-config'
require 'cantango/cache_ext'
module CanTango
View
@@ -0,0 +1,35 @@
+require 'rspec'
+require 'cantango-cache'
+require 'active_record'
+
+require 'cutter'
+require 'yaml'
+require 'logger'
+require 'database_cleaner'
+
+require 'factory_girl'
+FactoryGirl.find_definitions
+
+# Requires supporting files with custom matchers and macros, etc,
+# in ./support/ and its subdirectories.
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
+
+DatabaseCleaner.strategy = :truncation
+
+RSpec.configure do |config|
+end
+
+def connect_db
+ path = File.dirname(__FILE__) + '/db/database.yml'
+ dbfile = File.open(path)
+ dbconfig = YAML::load(dbfile)
+ ActiveRecord::Base.establish_connection(dbconfig)
+ ActiveRecord::Base.logger = Logger.new(STDERR)
+ DatabaseCleaner.clean
+end
+
+def migrate
+ folder = File.join(File.dirname(__FILE__), 'migrations')
+ puts "Migrate: #{folder}"
+ ActiveRecord::Migrator.migrate folder
+end

0 comments on commit 3fbf69f

Please sign in to comment.