require "yaml" class FixtureReader def initialize cleanup! end KEEP_TABLES = %i(meta) def apply!(id) path = File.join("test", "fixtures", "#{id}.yaml") data = YAML.load_file path data.each do |table, rows| rows.each { |row| LifePex::DB[table.to_sym].insert row } end end def cleanup! LifePex::DB.tables.reject { |table, _| KEEP_TABLES.include?(table) }.each do |table| LifePex::DB[table].truncate end end end