spec/lib/database_server_spec.rb in switchman-1.1.0 vs spec/lib/database_server_spec.rb in switchman-1.2.0

- old
+ new

@@ -64,12 +64,16 @@ new_shard.destroy end end it "should be able to create a new sqlite shard from a given server" do - @db = DatabaseServer.create(:config => { :adapter => 'sqlite3', :database => '%{shard_name}', :shard_name => ':memory:' }) - create_shard(@db) + db = DatabaseServer.create(:config => { :adapter => 'sqlite3', :database => '%{shard_name}', :shard_name => ':memory:' }) + begin + create_shard(db) + ensure + db.destroy + end end context "non-transactional" do self.use_transactional_fixtures = ::ActiveRecord::Base.connection.supports_ddl_transactions? @@ -81,11 +85,15 @@ it "should be able to create a new shard from a db server that doesn't have any shards" do # otherwise it's a repeat of the sqlite spec above pending 'A "real" database"' unless %w{MySQL Mysql2 PostgreSQL}.include?(adapter) # So, it's really the same server, but we want separate connections - server = DatabaseServer.create(:config => Shard.default.database_server.config) - create_shard(server) + db = DatabaseServer.create(:config => Shard.default.database_server.config) + begin + create_shard(db) + ensure + db.destroy + end end class MyException < Exception; end it "should use the connection's db name as temp db name" do db = DatabaseServer.new(config: { adapter: 'postgresql' })