require 'pathname' require Pathname(__FILE__).dirname.parent.expand_path + 'lib/simpledb_adapter' require 'logger' require 'fileutils' require 'spec' DOMAIN_FILE_MESSAGE = < THROW_AWAY_SDB_DOMAIN END Spec::Runner.configure do |config| access_key = ENV['AMAZON_ACCESS_KEY_ID'] secret_key = ENV['AMAZON_SECRET_ACCESS_KEY'] domain_file = File.expand_path('../THROW_AWAY_SDB_DOMAIN', File.dirname(__FILE__)) test_domain = if File.exist?(domain_file) File.read(domain_file).strip else warn DOMAIN_FILE_MESSAGE exit 1 end #For those that don't like to mess up their ENV if access_key==nil && secret_key==nil lines = File.readlines(File.join(File.dirname(__FILE__),'..','aws_config')) access_key = lines[0].strip secret_key = lines[1].strip end # Run just once config.before :suite do FileUtils.mkdir_p('log') unless File.exists?('log') log_file = "log/dm-sdb.log" FileUtils.touch(log_file) log = Logger.new(log_file) $control_sdb ||= RightAws::SdbInterface.new( access_key, secret_key, :domain => test_domain) DataMapper.logger.set_log(log_file, :debug) DataMapper.setup(:default, { :adapter => 'simpledb', :access_key => access_key, :secret_key => secret_key, :domain => test_domain, :logger => log, :wait_for_consistency => :manual }) end # Run before each group config.before :all do @adapter = DataMapper::Repository.adapters[:default] @sdb ||= $control_sdb @sdb.delete_domain(test_domain) @sdb.create_domain(test_domain) @domain = test_domain end end