Thinking Sphinx overwrites handcrafted Sphinx configuration files during Cucumber testing

21 views
Skip to first unread message

Ramón Cahenzli

unread,
Mar 22, 2011, 3:36:45 AM3/22/11
to thinkin...@googlegroups.com
Hi everyone,

We're switching from plain Rspec or Rspec + Steak to Cucumber for some of our tests, but every time we run Cucumber, our handcrafted test.sphinx.conf gets trashed by Thinking Sphinx and thus our system no longer works and all tests fail.

The issue is this: We use xmlpipe2 like so:

https://github.com/psy-q/madek/blob/master/config/test.sphinx.conf_with_pipe

Which works well. It seems the trouble with rake cucumber is this part of Thinking Sphinx:

lib/cucumber/thinking_sphinx/external_world.rb

Which reads:

require 'thinking_sphinx/test'

  module Cucumber
    module ThinkingSphinx
      class ExternalWorld
        def initialize(suppress_delta_output = true)
          ::ThinkingSphinx::Test.init
          ::ThinkingSphinx::Test.start_with_autostop
        end
      end
    end
  end

Test.start_with_autostop does this:

  def self.start_with_autostop
    autostop
    start
  end

And the trouble is here:

  def self.start
    config.build
    config.controller.index
    config.controller.start
  end

We don't want config.build to ever happen. I've tried overriding those methods with ones that don't do config.build in an initializer, but it seems that code is never executed when we run the Cucumber tests.

Do you have any suggestions how we could get ThinkingSphinx to stop overwriting its configuration file when using Cucumber?

Cheers,

Ramón

Ramón Cahenzli

unread,
Mar 22, 2011, 6:06:41 AM3/22/11
to thinkin...@googlegroups.com
Hi again,

I think we managed to solve this by monkey-patching things in a features/support/env_thinking_sphinx.rb file:


Cucumber::Rails::World.use_transactional_fixtures = false

# http://freelancing-god.github.com/ts/en/testing.html
require 'cucumber/thinking_sphinx/external_world'

# Monkeypatch thinking sphinx init in order to NOT overwrite
# the config - otherwise all our custom changes to the config
# are lost! See:
# http://groups.google.com/group/thinking-sphinx/browse_thread/thread/70dd3a663c3b9792#
class ThinkingSphinx::Test
  def self.start
    config.controller.index
    config.controller.start
  end
end

Cucumber::ThinkingSphinx::ExternalWorld.new

Pat Allan

unread,
Mar 22, 2011, 9:08:37 AM3/22/11
to thinkin...@googlegroups.com
Hi Ramón

The monkey patch is your best option at this point, I'm afraid. Good to know it's working for you.

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.

Reply all
Reply to author
Forward
0 new messages