class Cranium::TestFramework::DatabaseTable
Public Instance Methods
clear()
click to toggle source
# File lib/cranium/test_framework/database_table.rb, line 35 def clear connection[entity_name].truncate end
content(fields = ["*".to_sym])
click to toggle source
# File lib/cranium/test_framework/database_table.rb, line 23 def content(fields = ["*".to_sym]) connection[entity_name].select(*fields).all end
count()
click to toggle source
# File lib/cranium/test_framework/database_table.rb, line 17 def count connection[entity_name].count end
create(fields)
click to toggle source
# File lib/cranium/test_framework/database_table.rb, line 4 def create(fields) connection.run "CREATE TABLE #{entity_name} (#{fields.map { |field| "#{field[:field_name]} #{field[:field_type]}" }.join ", " })" self.class.entities_created << self end
destroy()
click to toggle source
# File lib/cranium/test_framework/database_table.rb, line 11 def destroy connection.run "DROP TABLE #{entity_name}" end
insert(data)
click to toggle source
# File lib/cranium/test_framework/database_table.rb, line 29 def insert(data) connection[entity_name].multi_insert data end