Sha256: cc7e500480fcb230761226774ba5e4812b7526fa83e47517c686a1726f70657e
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
# # Copyright (c) 2011, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias # Schmidt # require File.expand_path(File.dirname(__FILE__)) + "/../bootstrap" require 'active_record' require 'lhm/table' module IntegrationHelper delegate :select_one, :select_value, :execute, :to => :connection # # Connectivity # def connect! ActiveRecord::Base.establish_connection( :adapter => 'mysql', :database => 'lhm', :username => '', :host => 'localhost' ) ActiveRecord::Migration.verbose = !!ENV["VERBOSE"] end def connection ActiveRecord::Base.connection end # # Test Data # def fixture(name) File.read($fixtures.join("#{ name }.ddl")) end def table_create(fixture_name) execute "drop table if exists `#{ fixture_name }`" execute fixture(fixture_name) table_read(fixture_name) end def table_read(fixture_name) Lhm::Table.parse(fixture_name, connection) end def table_exists?(table) connection.table_exists?(table.name) end # # Database Helpers # def count(table, column, value) query = "select count(*) from #{ table } where #{ column } = '#{ value }'" select_value(query).to_i end def count_all(table) query = "select count(*) from #{ table }" select_value(query).to_i end def key?(table, cols) query = "show indexes in #{ table.name } where key_name = '#{ table.idx_name(cols) }'" !!select_value(query) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lhm-1.0.0.rc.1 | spec/integration/integration_helper.rb |