Class: TestData::DetectsDatabaseEmptiness

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

Instance Method Summary collapse

Constructor Details

#initializeDetectsDatabaseEmptiness

Returns a new instance of DetectsDatabaseEmptiness.



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

def initialize
  @config = TestData.config
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  result = ActiveRecord::Base.connection.execute <<~SQL
    select not exists (
      select from information_schema.tables
      where table_name = 'ar_internal_metadata'
    ) as empty
  SQL
  result.first["empty"]
end