Sha256: a727761ce2b778ed8fa90de1592c69966f92fcde26a922bef65ded2c69c5d5ee
Contents?: true
Size: 1.31 KB
Versions: 10
Compression:
Stored size: 1.31 KB
Contents
require 'ostruct' module ChronoTest::Matchers class Base attr_reader :table def matches?(table) table = table.table_name if table.respond_to?(:table_name) @table = table end private :matches? # This is an abstract class def failure_message_for_should_not failure_message_for_should.gsub(/to /, 'to not ') end protected def connection ChronoTest.connection end def temporal_schema ChronoModel::Adapter::TEMPORAL_SCHEMA end def history_schema ChronoModel::Adapter::HISTORY_SCHEMA end def public_schema 'public' end def select_value(sql, binds, name = nil) result = exec_query(sql, binds, name || 'select_value') result.rows.first.try(:[], 0) end def select_values(sql, binds, name = nil) result = exec_query(sql, binds, name || 'select_values') result.rows.map(&:first) end def select_rows(sql, binds, name = nil) exec_query(sql, binds, name || 'select_rows').rows end private FooColumn = OpenStruct.new(:name => '') def exec_query(sql, binds, name) binds.map! do |col, val| val ? [col, val] : [FooColumn, col] end connection.exec_query(sql, name, binds) end end end
Version data entries
10 entries across 10 versions & 1 rubygems