spec/integration/integration_helper.rb in lhm-1.0.0.rc.1 vs spec/integration/integration_helper.rb in lhm-1.0.0.rc2
- old
+ new
@@ -7,11 +7,10 @@
require 'active_record'
require 'lhm/table'
module IntegrationHelper
- delegate :select_one, :select_value, :execute, :to => :connection
#
# Connectivity
#
@@ -28,10 +27,22 @@
def connection
ActiveRecord::Base.connection
end
+ def select_one(*args)
+ connection.select_one(*args)
+ end
+
+ def select_value(*args)
+ connection.select_value(*args)
+ end
+
+ def execute(*args)
+ connection.execute(*args)
+ end
+
#
# Test Data
#
def fixture(name)
@@ -64,11 +75,11 @@
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) }'"
+ def key?(table, cols, type = :non_unique)
+ non_unique = type == :non_unique ? 1 : 0
+ query = "show indexes in #{ table.name } where key_name = '#{ table.idx_name(cols) }' and non_unique = #{ non_unique }"
!!select_value(query)
end
end
-