forked from pat/thinking-sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec_helper.rb
60 lines (46 loc) · 1.51 KB
/
spec_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$:.unshift File.dirname(__FILE__) + '/../lib'
Dir[File.join(File.dirname(__FILE__), '../vendor/*/lib')].each do |path|
$:.unshift path
end
require 'rubygems'
require 'fileutils'
require 'ginger'
require 'jeweler'
require "#{File.dirname(__FILE__)}/../lib/thinking_sphinx"
require 'will_paginate'
require "#{File.dirname(__FILE__)}/sphinx_helper"
ActiveRecord::Base.logger = Logger.new(StringIO.new)
Spec::Runner.configure do |config|
%w( tmp tmp/config tmp/log tmp/db ).each do |path|
FileUtils.mkdir_p "#{Dir.pwd}/#{path}"
end
Kernel.const_set :RAILS_ROOT, "#{Dir.pwd}/tmp" unless defined?(RAILS_ROOT)
sphinx = SphinxHelper.new
sphinx.setup_mysql
require "#{File.dirname(__FILE__)}/fixtures/models"
ThinkingSphinx.context.define_indexes
config.before :all do
%w( tmp tmp/config tmp/log tmp/db ).each do |path|
FileUtils.mkdir_p "#{Dir.pwd}/#{path}"
end
ThinkingSphinx.updates_enabled = true
ThinkingSphinx.deltas_enabled = true
ThinkingSphinx.suppress_delta_output = true
ThinkingSphinx::Configuration.instance.reset
ThinkingSphinx::Configuration.instance.database_yml_file = "spec/fixtures/sphinx/database.yml"
end
config.after :all do
FileUtils.rm_r "#{Dir.pwd}/tmp" rescue nil
end
end
def minimal_result_hashes(*instances)
instances.collect do |instance|
{
:weight => 21,
:attributes => {
'sphinx_internal_id' => instance.id,
'class_crc' => instance.class.name.to_crc32
}
}
end
end