Class: TestData::DetectsDatabaseExistence

Inherits:
Object
  • Object
show all
Defined in:
lib/test_data/detects_database_existence.rb

Instance Method Summary collapse

Constructor Details

#initializeDetectsDatabaseExistence

Returns a new instance of DetectsDatabaseExistence.



3
4
5
# File 'lib/test_data/detects_database_existence.rb', line 3

def initialize
  @config = TestData.config
end

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/test_data/detects_database_existence.rb', line 7

def call
  rows = ActiveRecord::Base.connection.execute "    select datname database_name\n    from pg_catalog.pg_database\n  SQL\n  rows.any? { |row|\n    row[\"database_name\"] == @config.database_name\n  }\nrescue ActiveRecord::NoDatabaseError\n  false\nend\n"