I put this under spec/models accessing database. But for controller spec under spec/controllers, I mocked Ultrasphinx::Search so that the controller spec is not accessing database.
(Note: The line with "system(..)" is one line.
It is shown to be multiple lines because of the space.)
require File.dirname(__FILE__) + '/../spec_helper'
describe "Ultrasphinx sample" do
fixtures :overviews
before(:each) do
system("cd #{RAILS_ROOT};
rake ultrasphinx:index RAILS_ENV=\"test\"")
system("cd #{RAILS_ROOT};
rake ultrasphinx:daemon:start RAILS_ENV=\"test\"
&> /dev/null")
end
after(:each) do
system("cd #{RAILS_ROOT};
rake ultrasphinx:daemon:stop RAILS_ENV=\"test\"
&> /dev/null")
end
it "should find text with 'test'" do
@search = Ultrasphinx::Search.new(:query => "test")
@search.run
@search.results.size.should == 2
end
end
No comments:
Post a Comment