Module: Ardb

Defined in:
lib/ardb/root_path.rb,
lib/ardb.rb,
lib/ardb/cli.rb,
lib/ardb/runner.rb,
lib/ardb/version.rb,
lib/ardb/record_spy.rb,
lib/ardb/adapter_spy.rb,
lib/ardb/adapter/base.rb,
lib/ardb/relation_spy.rb,
lib/ardb/test_helpers.rb,
lib/ardb/migration_helpers.rb

Overview

Use theses helpers in your test suite. They all generally assume Ardb has already been initialized by calling ‘Ardb.init`.

Defined Under Namespace

Modules: AdapterSpy, MigrationHelpers, RecordSpy, TestHelpers Classes: Adapter, CLI, CLIRB, Config, RelationSpy, RootPath, Runner

Constant Summary collapse

NotConfiguredError =
Class.new(RuntimeError)
VERSION =
"0.22.0"

Class Method Summary collapse

Class Method Details

.adapterObject



17
# File 'lib/ardb.rb', line 17

def self.adapter; Adapter.current; end

.configObject



14
# File 'lib/ardb.rb', line 14

def self.config; Config; end

.configure(&block) ⇒ Object



15
# File 'lib/ardb.rb', line 15

def self.configure(&block); Config.define(&block); end

.init(establish_connection = true) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ardb.rb', line 25

def self.init(establish_connection=true)
  require self.config.db_file
  validate!
  Adapter.init

  # setup AR
  ActiveRecord::Base.logger = self.config.logger
  if establish_connection
    ActiveRecord::Base.establish_connection(self.config.db_settings)
  end
end

.validate!Object



19
20
21
22
23
# File 'lib/ardb.rb', line 19

def self.validate!
  if !self.config.required_set?
    raise NotConfiguredError, "missing required configs"
  end
end