Sha256: 6c44d5a9c73ab321e33aa6b66e434e86544bb90d40aedbe8841df30d333931ba
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
RSpec.shared_context 'database setup' do all_tables = %i(users tasks users_tasks tags task_tags posts puppies accounts cards subscriptions notes destinations flights categories user_group test_inferrence test_bidirectional people dragons rabbits carrots names schema_migrations) cleared_dbs = [] before do unless cleared_dbs.include?(conn.database_type) all_tables.reverse.each { |table| conn.drop_table?(table) } cleared_dbs << conn.database_type end end let(:uri) do |example| meta = example.metadata adapters = ADAPTERS.select { |adapter| meta[adapter] } case adapters.size when 1 then DB_URIS.fetch(adapters.first) when 0 then raise 'No adapter specified' else raise "Ambiguous adapter configuration, got #{adapters.inspect}" end end let(:conn) { Sequel.connect(uri) } let(:database_type) { conn.database_type } let(:inferrable_relations) { [] } let(:conf) { TestConfiguration.new(:sql, conn) } let(:container) { ROM.container(conf) } let(:relations) { container.relations } let(:commands) { container.commands } before do conn.loggers << LOGGER inferrable_relations.each { |name| conf.relation(name) { schema(infer: true) } } end after do conn.disconnect # Prevent the auto-reconnect when the test completed # This will save from hardly reproducible connection run outs conn.pool.available_connections.freeze end after do inferrable_relations.reverse.each do |name| conn.drop_table?(name) end end def db_true if database_type == :oracle 'Y' else true end end def db_false if database_type == :oracle 'N' else false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rom-sql-2.0.0.beta2 | spec/shared/database_setup.rb |
rom-sql-2.0.0.beta1 | spec/shared/database_setup.rb |