Class: DatabaseCleaner::Spec::DatabaseHelper

Inherits:
Struct
  • Object
show all
Defined in:
lib/database_cleaner/spec/database_helper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



18
19
20
# File 'lib/database_cleaner/spec/database_helper.rb', line 18

def connection
  @connection
end

#dbObject

Returns the value of attribute db

Returns:

  • (Object)

    the current value of db



5
6
7
# File 'lib/database_cleaner/spec/database_helper.rb', line 5

def db
  @db
end

Class Method Details

.with_all_dbs(&block) ⇒ Object



6
7
8
9
10
# File 'lib/database_cleaner/spec/database_helper.rb', line 6

def self.with_all_dbs &block
  %w[mysql2 sqlite3 postgres].map(&:to_sym).each do |db|
    yield new(db)
  end
end

Instance Method Details

#setupObject



12
13
14
15
16
# File 'lib/database_cleaner/spec/database_helper.rb', line 12

def setup
  create_db
  establish_connection
  load_schema
end

#teardownObject



20
21
22
# File 'lib/database_cleaner/spec/database_helper.rb', line 20

def teardown
  drop_db
end