Sha256: c6dae3d372d19c722f486c9b5d3f6e44e4ffd64ac99d8449b4b60943a4313a55
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
class DB ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" def self.setup capture_stdout do ActiveRecord::Base.logger ActiveRecord::Schema.define(version: 1) do create_table :orders do |t| t.column :name, :string end create_table :users do |t| t.column :name, :string end create_table :relations, id: false do |t| t.string :name t.references :x, null: false t.references :y, null: false end end Order.reset_column_information end end def self.teardown if ActiveRecord::Base.connection.respond_to?(:data_sources) ActiveRecord::Base.connection.data_sources.each do |table| ActiveRecord::Base.connection.drop_table(table) end else ActiveRecord::Base.connection.tables.each do |table| ActiveRecord::Base.connection.drop_table(table) end end end private def self.capture_stdout(&block) real_stdout = $stdout $stdout = StringIO.new yield $stdout.string ensure $stdout = real_stdout end end class Order < ActiveRecord::Base end class User < ActiveRecord::Base end require_relative ('../../app/models/relation')
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
relation-0.1.5 | test/support/database.rb |
relation-0.1.3 | test/support/database.rb |
relation-0.1.1 | test/support/database.rb |