<commit_before>require 'spec_helper'

require 'dm-migrations'

require 'dm-core/spec/adapter_shared_spec'
require 'dm-do-adapter/spec/shared_spec'

module SQLLogHelper
  class SQLLogger
    attr_accessor :buffer
    def initialize
      @buffer = ""
    end

    def level; 0; end

    def debug(string)
      @buffer << string << "\n"
      # puts "#{string.gsub(/\n/m,"<br/>\n")}<br/>"
    end
  end

  def start_sql_log!
    return if @sql_log_on
    @sql_log_on = true
    @old_logger = DataObjects::Oracle.logger
    DataObjects::Oracle.logger = SQLLogger.new
  end

  def stop_sql_log!
    return unless @sql_log_on
    @sql_log_on = nil
    DataObjects::Oracle.logger = @old_logger
  end

  def clear_sql_log!
    return unless @sql_log_on
    DataObjects::Oracle.logger.buffer = ""
  end

  def sql_log_buffer
    DataObjects::Oracle.logger.buffer
  end
end


describe 'DataMapper::Adapters::OracleAdapter' do

  before :all do
    @adapter    = DataMapper.setup(:default, 'oracle://dm_core_test:dm_core_test@localhost/orcl')
    @repository = DataMapper.repository(@adapter.name)
  end
  
  it_should_behave_like "An Adapter"
  it_should_behave_like "A DataObjects Adapter"<commit_msg>Imported migrations speed up code from dm-core<commit_after>require 'spec_helper'

require 'dm-migrations'

require 'dm-core/spec/adapter_shared_spec'
require 'dm-do-adapter/spec/shared_spec'

module SQLLogHelper
  class SQLLogger
    attr_accessor :buffer
    def initialize
      @buffer = ""
    end

    def level; 0; end

    def debug(string)
      @buffer << string << "\n"
      # puts "#{string.gsub(/\n/m,"<br/>\n")}<br/>"
    end
  end

  def start_sql_log!
    return if @sql_log_on
    @sql_log_on = true
    @old_logger = DataObjects::Oracle.logger
    DataObjects::Oracle.logger = SQLLogger.new
  end

  def stop_sql_log!
    return unless @sql_log_on
    @sql_log_on = nil
    DataObjects::Oracle.logger = @old_logger
  end

  def clear_sql_log!
    return unless @sql_log_on
    DataObjects::Oracle.logger.buffer = ""
  end

  def sql_log_buffer
    DataObjects::Oracle.logger.buffer
  end
end


describe 'DataMapper::Adapters::OracleAdapter' do

  before :all do
    @adapter    = DataMapper.setup(:default, 'oracle://dm_core_test:dm_core_test@localhost/orcl')
    @repository = DataMapper.repository(@adapter.name)

    # speed up test execution
    @adapter.class_eval do
      auto_migrate_with :delete           # table data will be deleted instead of dropping and creating table
      auto_migrate_reset_sequences false  # primary key sequences will not be reset
    end

  end
  
  it_should_behave_like "An Adapter"
  it_should_behave_like "A DataObjects Adapter"
{'fraction_non_alphanumeric': 0.09731543624161074, 'fraction_numerical': 0.0007457121551081282, 'mean_word_length': 3.44205298013245, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3353248', 'n_tokens_mistral': 928, 'n_tokens_neox': 918, 'n_words': 202}