Skip to content

Commit

Permalink
Forced commit - start of a fix to multimodel searching
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Aug 17, 2008
1 parent 47a37de commit dc95153
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
15 changes: 6 additions & 9 deletions spec/spec_helper.rb
Expand Up @@ -9,26 +9,23 @@
require 'spec/sphinx_helper'

Spec::Runner.configure do |config|
# config.mock_with NotAMock::RspecMockFrameworkAdapter
%w( tmp tmp/config tmp/log tmp/db ).each do |path|
FileUtils.mkdir_p "#{Dir.pwd}/#{path}"
end

sphinx = SphinxHelper.new
sphinx.setup_mysql
require 'spec/fixtures/models'

# puts "Models:", ThinkingSphinx.indexed_models
require 'spec/fixtures/models'

config.before :all do
%w( tmp tmp/config tmp/log tmp/db ).each do |path|
FileUtils.mkdir_p "#{Dir.pwd}/#{path}"
end

config.before :all do
Kernel.const_set :RAILS_ROOT, "#{Dir.pwd}/tmp" unless defined?(RAILS_ROOT)

sphinx.setup_sphinx
sphinx.start
end

config.before :each do
config.after :each do
NotAMock::CallRecorder.instance.reset
NotAMock::Stubber.instance.reset
end
Expand Down
4 changes: 2 additions & 2 deletions spec/sphinx_helper.rb
Expand Up @@ -75,9 +75,9 @@ def index

def start
return if running?

cmd = "searchd --config #{@configuration.config_file}"
`#{cmd}`
`#{cmd}`

sleep(1)

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/thinking_sphinx/active_record_spec.rb
Expand Up @@ -21,7 +21,7 @@ class TestModel < ActiveRecord::Base; end
# Remove the class so we can redefine it
TestModule.send(:remove_const, :TestModel)

ThinkingSphinx::Index.unstub_method(:new)
ThinkingSphinx.indexed_models.delete "TestModule::TestModel"
end

it "should return nil and do nothing if indexes are disabled" do
Expand Down
16 changes: 5 additions & 11 deletions spec/unit/thinking_sphinx/configuration_spec.rb
Expand Up @@ -81,8 +81,8 @@ module Merb; end

Person.unstub_method :indexes
Friendship.unstub_method :indexes

FileUtils.rm_rf "#{@config.app_root}/config"
#
# FileUtils.rm_rf "#{@config.app_root}/config"
end

it "should load the models" do
Expand Down Expand Up @@ -239,9 +239,7 @@ module Merb; end
describe "core_index_for_model method" do
before :each do
@config = ThinkingSphinx::Configuration.new
@model = Class.stub_instance(
:indexes => [ThinkingSphinx::Index.new(Person)]
)
@model = Person
end

it "should take its name from the model, with _core appended" do
Expand Down Expand Up @@ -399,9 +397,7 @@ module Merb; end
describe "delta_index_for_model method" do
before :each do
@config = ThinkingSphinx::Configuration.new
@model = Class.stub_instance(
:indexes => [ThinkingSphinx::Index.new(Person)]
)
@model = Person
end

it "should take its name from the model, with _delta appended" do
Expand All @@ -427,9 +423,7 @@ module Merb; end
describe "distributed_index_for_model method" do
before :each do
@config = ThinkingSphinx::Configuration.new
@model = Class.stub_instance(
:indexes => [ThinkingSphinx::Index.new(Person)]
)
@model = Person
end

it "should take its name from the model" do
Expand Down

0 comments on commit dc95153

Please sign in to comment.