Sha256: 62702d17cf222d8edad6fbb55ec11669ec15236f2d090d5c28879163205cc16b

Contents?: true

Size: 1009 Bytes

Versions: 5

Compression:

Stored size: 1009 Bytes

Contents

require 'rubygems'
unless Object.const_defined?('Sequel')
  $:.unshift(File.join(File.dirname(__FILE__), "../../lib/"))
  require 'sequel_core'
end

class MockDataset < Sequel::Dataset
  def insert(*args)
    @db.execute insert_sql(*args)
  end
  
  def update(*args)
    @db.execute update_sql(*args)
  end
  
  def fetch_rows(sql)
    @db.execute(sql)
    yield({:id => 1, :x => 1})
  end

  def quoted_identifier(c)
    "\"#{c}\""
  end
end

class MockDatabase < Sequel::Database
  @@quote_identifiers = false
  self.identifier_input_method = nil
  self.identifier_output_method = nil
  attr_reader :sqls
  
  def execute(sql, opts={})
    @sqls ||= []
    @sqls << sql
  end

  def reset
    @sqls = []
  end

  def transaction; yield; end
  
  def dataset; MockDataset.new(self); end
end

class SchemaDummyDatabase < Sequel::Database
  attr_reader :sqls
  self.identifier_input_method = nil
  self.identifier_output_method = nil
  
  def execute(sql, opts={})
    @sqls ||= []
    @sqls << sql
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
colincasey-sequel-2.10.1 spec/sequel_core/spec_helper.rb
colincasey-sequel-2.10.2 spec/sequel_core/spec_helper.rb
colincasey-sequel-2.10.4 spec/sequel_core/spec_helper.rb
sequel-2.11.0 spec/sequel_core/spec_helper.rb
sequel-2.10.0 spec/sequel_core/spec_helper.rb