require_relative '../lib/fossil' #gem "rspec", '1.3.0' require 'rspec' require 'rr' require 'logger' p RUBY_VERSION unless defined?(DB_DEMO) DB_DEMO = Sequel.odbc('demodata') #, :loggers=>[Logger.new($stdout)]) DB_DEMO.extend(Sequel::Pervasive::DatabaseMethods) DB_FOS = Sequel.odbc('fos', :loggers=>[Logger.new($stdout)]) DB_FOS.extend(Sequel::Pervasive::DatabaseMethods) end require File.dirname(__FILE__) + "/helper_methods" require File.dirname(__FILE__) + "/helper_classes" ##### custom matchers ##### require File.dirname(__FILE__) + "/be_model_with_values_matcher" RSpec.configure do |config| config.mock_with :rr config.include(HelperMethods) config.mock_with :rr config.include(BeModelWithValuesMatcher) end RSpec::Matchers.define :equal_xml do |expected| match do |actual| actual.gsub(/\s/, '').should == expected.gsub(/\s/, '') end end module Sequel::Pervasive::DatabaseMethods # turn autocommit offffffffff def connect(server) conn = super(server) conn.autocommit = false conn end # overriding execute to be able to rollback after each call # def execute(sql, opts={}) # log_info(sql) # synchronize(opts[:server]) do |conn| # begin # r = conn.run(sql) # yield(r) if block_given? # rescue Exception => e # raise_error(e, :disconnect=>e.message.match(/08S01/)) # ensure # ######### ROLLLLLLLBACK ########### # r1 = conn.run("rollback"); r1.drop # r.drop if r # end # nil # end # end end # These are special modifictations for testing with mysql db instead of pervasive # if its not windows or linux where pervasive db is running ) .. modify the # pervasive adapter to act more like mysql, so that the tests can still run. # This is not ideal, but it works #unless RUBY_PLATFORM =~ /mswin32|linux/ # # module Sequel::Pervasive::DatabaseMethods # def auto_increment_sql; "AUTO_INCREMENT" end # def begin_transaction_sql; "BEGIN" end # def commit_transaction_sql; "COMMIT" end # def rollback_transaction_sql; "ROLLBACK" end # end # # module Sequel::Pervasive::DatasetMethods # def quoted_identifier(name, convert=true) # convert ? "`#{convert_aliased_col_to_real_col(name)}`" : "`#{name}`" # end # # def select_clause_methods # super # end # # def select_limit_sql(sql) # super(sql) # end # end # #end