2010-08-27 16:35:26 -04:00
|
|
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
|
|
|
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
2009-10-14 23:03:38 -04:00
|
|
|
require 'aasm'
|
2011-01-13 02:58:20 -05:00
|
|
|
require 'rspec'
|
2015-10-30 06:47:13 -04:00
|
|
|
require 'aasm/rspec'
|
2016-02-18 02:01:52 -05:00
|
|
|
require 'pry'
|
2011-09-08 13:20:48 -04:00
|
|
|
|
|
|
|
# require 'ruby-debug'; Debugger.settings[:autoeval] = true; debugger; rubys_debugger = 'annoying'
|
|
|
|
# require 'ruby-debug/completion'
|
2013-04-28 11:57:34 -04:00
|
|
|
# require 'pry'
|
2009-10-14 23:03:38 -04:00
|
|
|
|
2015-01-18 18:55:02 -05:00
|
|
|
SEQUEL_DB = defined?(JRUBY_VERSION) ? 'jdbc:sqlite::memory:' : 'sqlite:/'
|
|
|
|
|
2011-08-31 17:49:09 -04:00
|
|
|
def load_schema
|
2015-05-16 00:32:58 -04:00
|
|
|
require 'logger'
|
2011-08-31 17:49:09 -04:00
|
|
|
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
|
|
|
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
|
|
|
ActiveRecord::Base.establish_connection(config['sqlite3'])
|
2014-01-11 06:12:29 -05:00
|
|
|
require File.dirname(__FILE__) + "/database.rb"
|
2011-08-31 17:49:09 -04:00
|
|
|
end
|
2011-09-16 10:57:23 -04:00
|
|
|
|
2015-12-31 13:47:55 -05:00
|
|
|
# Dynamoid initialization
|
|
|
|
begin
|
|
|
|
require 'dynamoid'
|
|
|
|
require 'aws-sdk-resources'
|
|
|
|
|
|
|
|
ENV['ACCESS_KEY'] ||= 'abcd'
|
|
|
|
ENV['SECRET_KEY'] ||= '1234'
|
|
|
|
|
|
|
|
Aws.config.update({
|
|
|
|
region: 'us-west-2',
|
|
|
|
credentials: Aws::Credentials.new(ENV['ACCESS_KEY'], ENV['SECRET_KEY'])
|
|
|
|
})
|
|
|
|
|
|
|
|
Dynamoid.configure do |config|
|
|
|
|
config.namespace = "dynamoid_tests"
|
|
|
|
config.endpoint = 'http://127.0.0.1:30180'
|
|
|
|
config.warn_on_scan = false
|
|
|
|
end
|
|
|
|
|
|
|
|
Dynamoid.logger.level = Logger::FATAL
|
|
|
|
|
|
|
|
RSpec.configure do |c|
|
|
|
|
c.before(:each) do
|
|
|
|
Dynamoid.adapter.list_tables.each do |table|
|
|
|
|
Dynamoid.adapter.delete_table(table) if table =~ /^#{Dynamoid::Config.namespace}/
|
|
|
|
end
|
|
|
|
Dynamoid.adapter.tables.clear
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
# Without Dynamoid settings
|
|
|
|
end
|
|
|
|
|
2013-04-21 12:43:03 -04:00
|
|
|
# custom spec helpers
|
2011-09-16 10:57:23 -04:00
|
|
|
Dir[File.dirname(__FILE__) + "/spec_helpers/**/*.rb"].sort.each { |f| require File.expand_path(f) }
|
2013-04-21 12:43:03 -04:00
|
|
|
|
|
|
|
# example model classes
|
|
|
|
Dir[File.dirname(__FILE__) + "/models/*.rb"].sort.each { |f| require File.expand_path(f) }
|