1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/spec/spec_helper.rb

60 lines
1.7 KiB
Ruby
Raw Permalink Normal View History

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'
require 'rspec'
2015-10-30 06:47:13 -04:00
require 'aasm/rspec'
require 'pry'
# 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
SEQUEL_DB = defined?(JRUBY_VERSION) ? 'jdbc:sqlite::memory:' : 'sqlite:/'
def load_schema
2015-05-16 00:32:58 -04:00
require 'logger'
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'])
require File.dirname(__FILE__) + "/database.rb"
end
# 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
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) }