Stubbing ThinkingSphinx 'search' method in Rspec

Hello everyone,

I’m trying to test if the ‘search’ method is called with a right params
in
my controller. When run this right inside my spec:

    Document.stub!(:search).and_return([@document])
    Document.search

everything goes fine(no errors). But if try:

    Document.stub!(:search).and_return([@document])
    get :index, :search => 'foo'

and the search method ‘called’ inside controller, It falls with this
error:

Riddle::ConnectionError in ‘DocumentsController GET index blah blah’
Connection to 127.0.0.1 on 9312 failed. Connection refused - connect(2)
(full stack trace
here http://pastie.org/pastes/1864689/text?key=1vlusmdf1xer2tz1ve7pvg )

So why it’s even trying to call stubbed method from ThinkingSphinx? I’ve
also tried to stub

   ThinkingSphinx::Search.stub!(:search)

but results are the same. I use standard Rspec’s stubbing. But also
tried
with mocha’s stubs() - all the same error.

I don’t really want to do ThinkingSphinx::Test.start and start the
daemon,
do indexing etc. My environment is:

Ruby 1.8.7 on RVM
Rails 2.3.9
Rspec 1.3.0
Rspec-Rails 1.3.2
ThinkingSphinx 1.4.3
Riddle 1.2.2
Ubuntu Linux 10.04

Any thoughts?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs