spec/spec_helper.rb in earth-0.12.4 vs spec/spec_helper.rb in earth-1.0.0

- old
+ new

@@ -1,56 +1,47 @@ -require 'rubygems' -require 'bundler' -Bundler.setup -require 'logger' +require 'bundler/setup' + require 'active_record' require 'data_miner' -$LOAD_PATH.unshift(File.dirname(__FILE__)) -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -require 'earth' +require 'factory_girl' + +ENV['EARTH_ENV'] ||= 'test' +ENV['DATABASE_URL'] ||= 'mysql2://root:password@localhost/test_earth' + require 'support/integration' include Integration -case ENV['EARTH_DB_ADAPTER'] -when 'mysql' - adapter = 'mysql2' - database = 'test_earth' - username = 'root' - password = 'password' - - # system %{mysql -u #{username} -p#{password} -e "DROP DATABASE #{database}"} - # system %{mysql -u #{username} -p#{password} -e "CREATE DATABASE #{database}"} -else - adapter = 'postgresql' - database = 'test_earth' - username = nil - password = nil -end - -config = { - 'encoding' => 'utf8', - 'adapter' => adapter, - 'database' => database, -} -config['username'] = username if username -config['password'] = password if password - -ActiveRecord::Base.establish_connection config - +require 'logger' logger = Logger.new 'log/test.log' -logger.level = Logger::DEBUG - ActiveRecord::Base.logger = logger DataMiner.logger = logger -DataMiner::Run.auto_upgrade! DataMiner.unit_converter = :conversions RSpec.configure do |c| unless ENV['ALL'] == 'true' + c.filter_run_excluding :sanity => true c.filter_run_excluding :data_miner => true end if ENV['SKIP_FLIGHT_SEGMENT'] == 'true' c.filter_run_excluding :flight_segment => true + end + + c.before :all do + require 'earth' + Earth.init :mine_original_sources => true, :connect => true + end + c.before :all, :sanity => true do + described_class.run_data_miner! + end + + c.before(:each) do + ActiveRecord::Base.connection.increment_open_transactions + ActiveRecord::Base.connection.transaction_joinable = false + ActiveRecord::Base.connection.begin_db_transaction + end + c.after(:each) do + ActiveRecord::Base.connection.rollback_db_transaction + ActiveRecord::Base.connection.decrement_open_transactions end end