Module: DatabaseRewinder::Compatibility
- Included in:
- DatabaseRewinder
- Defined in:
- lib/database_rewinder/compatibility.rb
Instance Method Summary collapse
-
#[](orm, connection: nil) ⇒ Object
In order to add another database to cleanup, you can give its connection name in one of the forms below:.
- #clean_with(*args) ⇒ Object
- #cleaning ⇒ Object
- #start ⇒ Object
- #strategy=(args) ⇒ Object
Instance Method Details
#[](orm, connection: nil) ⇒ Object
In order to add another database to cleanup, you can give its connection name in one of the forms below:
# the simplest form
DatabaseRewinder['the_db_name']
or
# with connection: key
DatabaseRewinder[connection: 'the_db_name']
or
# DatabaseCleaner compatible
DatabaseRewinder[:active_record, connection: 'the_db_name']
You can cleanup multiple databases for each test using this configuration.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/database_rewinder/compatibility.rb', line 37 def [](orm, connection: nil, **) if connection.nil? if orm.is_a? String connection = orm elsif orm.is_a?(Hash) && orm.key?(:connection) connection = orm[:connection] end end super connection end |
#clean_with(*args) ⇒ Object
3 4 5 |
# File 'lib/database_rewinder/compatibility.rb', line 3 def clean_with(*args) cleaners.each {|c| c.clean_with(*args)} end |
#cleaning ⇒ Object
7 8 9 10 11 |
# File 'lib/database_rewinder/compatibility.rb', line 7 def cleaning yield ensure clean end |
#start ⇒ Object
13 |
# File 'lib/database_rewinder/compatibility.rb', line 13 def start; end |
#strategy=(args) ⇒ Object
15 16 17 18 19 |
# File 'lib/database_rewinder/compatibility.rb', line 15 def strategy=(args) = args.is_a?(Array) ? args. : {} @only, @except = [:only], [:except] cleaners.each {|c| c.strategy = nil, } end |