Module: DatabaseCleaner
- Defined in:
- lib/database_cleaner/base.rb,
lib/database_cleaner/generic/base.rb,
lib/database_cleaner/mongoid/base.rb,
lib/database_cleaner/configuration.rb,
lib/database_cleaner/null_strategy.rb,
lib/database_cleaner/data_mapper/base.rb,
lib/database_cleaner/mongo/truncation.rb,
lib/database_cleaner/couch_potato/base.rb,
lib/database_cleaner/mongo_mapper/base.rb,
lib/database_cleaner/active_record/base.rb,
lib/database_cleaner/generic/truncation.rb,
lib/database_cleaner/mongoid/truncation.rb,
lib/database_cleaner/data_mapper/truncation.rb,
lib/database_cleaner/couch_potato/truncation.rb,
lib/database_cleaner/mongo_mapper/truncation.rb
Defined Under Namespace
Modules: ActiveRecord, CouchPotato, DataMapper, Generic, Mongo, MongoMapper, Mongoid
Classes: Base, NoORMDetected, NullStrategy, UnknownStrategySpecified
Class Method Summary
collapse
Class Method Details
.[](orm, opts = {}) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/database_cleaner/configuration.rb', line 9
def [](orm,opts = {})
raise NoORMDetected if orm.nil?
@connections ||= []
cleaner = DatabaseCleaner::Base.new(orm,opts)
connections.push cleaner
cleaner
end
|
.app_root ⇒ Object
21
22
23
|
# File 'lib/database_cleaner/configuration.rb', line 21
def app_root
@app_root || Dir.pwd
end
|
.app_root=(desired_root) ⇒ Object
17
18
19
|
# File 'lib/database_cleaner/configuration.rb', line 17
def app_root=(desired_root)
@app_root = desired_root
end
|
.clean ⇒ Object
Also known as:
clean!
55
56
57
|
# File 'lib/database_cleaner/configuration.rb', line 55
def clean
self.connections.each { |connection| connection.clean }
end
|
.clean_with(*args) ⇒ Object
Also known as:
clean_with!
61
62
63
|
# File 'lib/database_cleaner/configuration.rb', line 61
def clean_with(*args)
self.connections.each { |connection| connection.clean_with(*args) }
end
|
.connections ⇒ Object
25
26
27
|
# File 'lib/database_cleaner/configuration.rb', line 25
def connections
@connections ||= [::DatabaseCleaner::Base.new]
end
|
.logger ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/database_cleaner/configuration.rb', line 33
def logger
return @logger if @logger
@logger = Logger.new(STDOUT)
@logger.level = Logger::ERROR
@logger
end
|
.logger=(log_source) ⇒ Object
29
30
31
|
# File 'lib/database_cleaner/configuration.rb', line 29
def logger=(log_source)
@logger = log_source
end
|
.orm=(orm) ⇒ Object
46
47
48
49
|
# File 'lib/database_cleaner/configuration.rb', line 46
def orm=(orm)
self.connections.each { |connect| connect.orm = orm }
remove_duplicates
end
|
.orm_module(symbol) ⇒ Object
.remove_duplicates ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/database_cleaner/configuration.rb', line 67
def remove_duplicates
temp = []
self.connections.each do |connect|
temp.push connect unless temp.include? connect
end
@connections = temp
end
|
.start ⇒ Object
51
52
53
|
# File 'lib/database_cleaner/configuration.rb', line 51
def start
self.connections.each { |connection| connection.start }
end
|
.strategy=(stratagem) ⇒ Object
41
42
43
44
|
# File 'lib/database_cleaner/configuration.rb', line 41
def strategy=(stratagem)
self.connections.each { |connect| connect.strategy = stratagem }
remove_duplicates
end
|