Module: Cutest::Database
- Extended by:
- Database
- Included in:
- Database
- Defined in:
- lib/cutest/database/sequel_driver.rb,
lib/cutest/database/activerecord_driver.rb
Defined Under Namespace
Modules: Helper
Instance Method Summary collapse
- #config ⇒ Object
- #connect(database = false) ⇒ Object
- #reset(database = false, options = {}) ⇒ Object
Instance Method Details
#config ⇒ Object
29 30 31 |
# File 'lib/cutest/database/sequel_driver.rb', line 29 def config Cutest.config.database.clone end |
#connect(database = false) ⇒ Object
25 26 27 |
# File 'lib/cutest/database/sequel_driver.rb', line 25 def connect database = false @db ||= Sequel.connect database || config[:url] end |
#reset(database = false, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cutest/database/sequel_driver.rb', line 5 def reset database = false, = {} db = connect database c = config.merge ignore_tables = %w(schema_migrations) if c.key? :ignore_tables ignore_tables.concat c[:ignore_tables] end db.tables.each do |t| unless ignore_tables.include? t db.run("SET FOREIGN_KEY_CHECKS = 0") db.run("TRUNCATE #{t}") db.run("SET FOREIGN_KEY_CHECKS = 1") end end end |