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

move dynamoid loading and initialisation into its own file

This commit is contained in:
Thorsten Böttger 2017-02-10 22:18:05 +11:00
parent 0a11594066
commit 57f18bac89
4 changed files with 40 additions and 49 deletions

View file

@ -19,39 +19,6 @@ def load_schema
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
# custom spec helpers
Dir[File.dirname(__FILE__) + "/spec_helpers/**/*.rb"].sort.each { |f| require File.expand_path(f) }

View file

@ -0,0 +1,32 @@
begin
require 'dynamoid'
require 'aws-sdk-resources'
puts "dynamoid gem found, running Dynamoid specs \e[32m#{'✔'}\e[0m"
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
puts "dynamoid gem not found, not running Dynamoid specs \e[31m#{'✖'}\e[0m"
end

View file

@ -1,9 +1,7 @@
describe 'dynamoid' do
begin
require 'dynamoid'
require 'logger'
require 'spec_helper'
puts "dynamoid gem found, running Dynamoid specs \e[32m#{'✔'}\e[0m"
require 'spec_helper'
if defined?(Dynamoid)
describe 'dynamoid' do
Dir[File.dirname(__FILE__) + "/../../models/dynamoid/*.rb"].sort.each do |f|
require File.expand_path(f)
@ -133,7 +131,5 @@ describe 'dynamoid' do
end
end
rescue LoadError
puts "dynamoid gem not found, not running Dynamoid specs \e[31m#{'✖'}\e[0m"
end
end

View file

@ -1,9 +1,7 @@
describe 'dynamoid' do
begin
require 'dynamoid'
require 'logger'
require 'spec_helper'
puts "dynamoid gem found, running Dynamoid specs \e[32m#{'✔'}\e[0m"
require 'spec_helper'
if defined?(Dynamoid)
describe 'dynamoid' do
Dir[File.dirname(__FILE__) + "/../../models/dynamoid/*.rb"].sort.each do |f|
require File.expand_path(f)
@ -82,7 +80,5 @@ describe 'dynamoid' do
end
end
rescue LoadError
puts "dynamoid gem not found, not running Dynamoid specs \e[31m#{'✖'}\e[0m"
end
end