spec/integration/gateway_spec.rb in rom-sql-0.7.0 vs spec/integration/gateway_spec.rb in rom-sql-0.8.0
- old
+ new
@@ -1,16 +1,14 @@
-require 'spec_helper'
-
describe ROM::SQL::Gateway do
describe 'migration' do
- let(:conn) { Sequel.connect(DB_URI) }
+ let(:conn) { Sequel.connect(POSTGRES_DB_URI) }
context 'creating migrations inline' do
subject(:gateway) { container.gateways[:default] }
- let(:configuration) { ROM::Configuration.new(:sql, conn) }
- let!(:container) { ROM.container(configuration) }
+ let(:conf) { ROM::Configuration.new(:sql, conn) }
+ let!(:container) { ROM.container(conf) }
after do
[:rabbits, :carrots].each do |name|
gateway.connection.drop_table?(name)
end
@@ -46,12 +44,12 @@
let(:migration_dir) do
Pathname(__FILE__).dirname.join('../fixtures/migrations').realpath
end
let(:migrator) { ROM::SQL::Migration::Migrator.new(conn, path: migration_dir) }
- let(:configuration) { ROM::Configuration.new(:sql, [conn, migrator: migrator]) }
- let!(:container) { ROM.container(configuration) }
+ let(:conf) { ROM::Configuration.new(:sql, [conn, migrator: migrator]) }
+ let!(:container) { ROM.container(conf) }
it 'returns true for pending migrations' do
expect(container.gateways[:default].pending_migrations?).to be_truthy
end
@@ -68,34 +66,28 @@
context 'setting up' do
include_context 'database setup'
it 'skips settings up associations when tables are missing' do
- configuration = ROM::Configuration.new(:sql, uri) do |config|
- config.use(:macros)
-
+ conf = ROM::Configuration.new(:sql, uri) do |config|
config.relation(:foos) do
use :assoc_macros
- primary_key :id
one_to_many :bars, key: :foo_id
end
end
- expect { ROM.container(configuration) }.not_to raise_error
+ expect { ROM.container(conf) }.not_to raise_error
end
it 'skips finalization a relation when table is missing' do
- configuration = ROM::Configuration.new(:sql, uri) do |config|
- config.use(:macros)
-
+ conf = ROM::Configuration.new(:sql, uri) do |config|
class Foos < ROM::Relation[:sql]
dataset :foos
use :assoc_macros
- primary_key :id
one_to_many :bars, key: :foo_id
end
end
- expect { ROM.container(configuration) }.not_to raise_error
+ expect { ROM.container(conf) }.not_to raise_error
expect { Foos.model.dataset }.to raise_error(Sequel::Error, /no dataset/i)
end
end
end