summaryrefslogtreecommitdiff
path: root/vendor/plugins/thinking-sphinx/features/support/post_database.rb
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/plugins/thinking-sphinx/features/support/post_database.rb')
-rw-r--r--vendor/plugins/thinking-sphinx/features/support/post_database.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/plugins/thinking-sphinx/features/support/post_database.rb b/vendor/plugins/thinking-sphinx/features/support/post_database.rb
new file mode 100644
index 0000000..51cefb5
--- /dev/null
+++ b/vendor/plugins/thinking-sphinx/features/support/post_database.rb
@@ -0,0 +1,37 @@
1$:.unshift File.dirname(__FILE__) + '/../../lib'
2
3require 'lib/thinking_sphinx'
4
5%w( tmp/config tmp/log tmp/db/sphinx/development ).each do |path|
6 FileUtils.mkdir_p "#{Dir.pwd}/#{path}"
7end
8
9Kernel.const_set :RAILS_ROOT, "#{Dir.pwd}/tmp" unless defined?(RAILS_ROOT)
10
11at_exit do
12 ThinkingSphinx::Configuration.instance.controller.stop
13 sleep(1) # Ensure Sphinx has shut down completely
14 FileUtils.rm_r "#{Dir.pwd}/tmp"
15end
16
17# Add log file
18ActiveRecord::Base.logger = Logger.new open("tmp/active_record.log", "a")
19
20ThinkingSphinx.deltas_enabled = false
21
22# Load Models
23Dir["features/support/models/*.rb"].sort.each do |file|
24 require file.gsub(/\.rb$/, '')
25end
26
27# Set up database tables and records
28Dir["features/support/db/migrations/*.rb"].each do |file|
29 require file.gsub(/\.rb$/, '')
30end
31
32ThinkingSphinx.deltas_enabled = true
33ThinkingSphinx.suppress_delta_output = true
34
35ThinkingSphinx::Configuration.instance.build
36ThinkingSphinx::Configuration.instance.controller.index
37ThinkingSphinx::Configuration.instance.controller.start