Sha256: f6db01065683895eb6c707271eb5bdcf0597d3c42614c2e34416bdabf60889a8

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

$VERBOSE = false # Shitloads of warnings in dm :(
require 'rubygems'
require 'extlib'
require 'extlib/hook'
require 'pathname'
require 'shoulda'
require 'test/unit'

base  = Pathname.new(__FILE__).dirname + '..'
files = base + 'test' + 'files'
%w{lib test}.each{|p| $:.unshift base + p}

require 'dm-sphinx-adapter'

# Sphinx runner.
Dir.chdir(base)
begin
  TCPSocket.new('localhost', '3312')
rescue
  puts 'Starting Sphinx...'
  system("searchd --config #{files + 'sphinx.conf'}") || exit
  system('ps aux | grep searchd')
end

indexer = `indexer --config #{files + 'sphinx.conf'} --all --rotate`
raise %{Re-create index failed:\n #{indexer}} if indexer =~ /error|fatal/i
sleep 1

# :default is unused at the moment.
DataMapper.setup(:default, :adapter => 'in_memory', :database => 'dm_sphinx_adapter_test')
DataMapper.setup(:search,  :adapter => 'sphinx')

class Test::Unit::TestCase
  include Extlib::Hook

  # after :teardown do
  def teardown
    descendants = DataMapper::Resource.descendants.dup.to_a
    while model = descendants.shift
      descendants.concat(model.descendants) if model.respond_to?(:descendants)
      Object.send(:remove_const, model.name.to_sym)
      DataMapper::Resource.descendants.delete(model)
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
shanna-dm-sphinx-adapter-0.7.1 test/helper.rb
shanna-dm-sphinx-adapter-0.7 test/helper.rb
dm-sphinx-adapter-0.7 test/helper.rb