<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>opensoul.org - Cucumber scenarios that depend on Sphinx Comments</title>
  <id>tag:opensoul.org,2009:/2009/6/1/cucumber-scenarios-that-depend-on-sphinx/comments</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx/comments.xml" rel="self" type="application/atom+xml"/>
  <link href="/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
  <updated>2009-09-29T10:44:14Z</updated>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Guillermo</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:17900</id>
    <published>2009-09-29T10:44:14Z</published>
    <updated>2009-09-29T10:44:14Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Guillermo</title>
<content type="html">I don&#8217;t disable transactions, so i write a method to commit the status before index:
&lt;pre&gt;
Given /^the search index was generated$/ do
  without_transactions do
    TS.controller.index
  end
end
&lt;/pre&gt;

without_transactions  method just commit current transactions, yield, and create transactions again:
&lt;pre&gt;
def without_transactions
  @__cucumber_ar_connection.open_transactions.times do
    @__cucumber_ar_connection.commit_db_transaction
  end
  yield
  @__cucumber_ar_connection.open_transactions.times do
    @__cucumber_ar_connection.begin_db_transaction
  end
end
&lt;/pre&gt;

Features that use &#8220;the search index was generated&#8221; step, should be tagged with @sphinx, so i can just do
&lt;pre&gt;
Before('@sphinx') do
  TS.build
  FileUtils.mkdir_p TS.searchd_file_path
  TS.controller.start
end

After('@sphinx') do
  TS.controller.stop
  reset_database!
end
&lt;/pre&gt;

	&lt;p&gt;The reset_database! use without_transaction and do something similar to database_cleaner.&lt;/p&gt;


	&lt;p&gt;By this way, i can use transactions in all of my code. I just need to reset the database in features (or scenarios) tagged as @sphinx&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>bmsatierf</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:17319</id>
    <published>2009-09-08T17:02:54Z</published>
    <updated>2009-09-08T17:02:54Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by bmsatierf</title>
<content type="html">&lt;p&gt;Great!&lt;/p&gt;


	&lt;p&gt;Thank you very much.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>schlick</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:15363</id>
    <published>2009-06-26T03:39:54Z</published>
    <updated>2009-06-26T03:39:54Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by schlick</title>
<content type="html">Alternatively, you can keep the database cleaning at the start of each scenario and simply perform a final clean at the end of all your tests using:
&lt;pre&gt;
at_exit do
  DatabaseCleaner.clean
end
&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Erik Ostrom</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:15264</id>
    <published>2009-06-23T22:38:55Z</published>
    <updated>2009-06-23T22:38:55Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Erik Ostrom</title>
<content type="html">&lt;p&gt;For my cucumber features I&#8217;ve been using fixtures, loaded from env.rb, and transactional fixtures to reset them after each scenario. Working from your post, I disabled transactional fixtures, and replaced them with DatabaseCleaner&#8217;s truncation. When I ran the scenarios, my fixtures were all gone!&lt;/p&gt;


I think this is because, well, I was deleting them before each scenario. From the DatabaseCleaner &lt;span class=&quot;caps&quot;&gt;README&lt;/span&gt;, it seems the preferred approach is to clean &lt;em&gt;after&lt;/em&gt; each scenario:
&lt;pre&gt;require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
Before do
  DatabaseCleaner.start
end
After do
  DatabaseCleaner.clean
end&lt;/pre&gt;
Clean-before will work with other fixture strategies, but I don&#8217;t think there&#8217;s a down side to clean-after.</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>schlick</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:15075</id>
    <published>2009-06-19T12:47:47Z</published>
    <updated>2009-06-19T12:47:47Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by schlick</title>
<content type="html">&lt;p&gt;Yep, it really works now. Excellent work!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Tim Riley</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14959</id>
    <published>2009-06-17T00:43:30Z</published>
    <updated>2009-06-17T00:43:30Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Tim Riley</title>
<content type="html">&lt;p&gt;Thank you for this post! This has helped us finally provide coverage for the only part of our application that lacked cucumber features.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Brandon</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14768</id>
    <published>2009-06-13T02:06:56Z</published>
    <updated>2009-06-13T02:06:56Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Brandon</title>
<content type="html">&lt;p&gt;I&#8217;ve updated the post again.  Now it &lt;em&gt;really&lt;/em&gt; works without already having the test index generated.  Let me know if you have any other issues.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>schlick</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14723</id>
    <published>2009-06-11T13:40:55Z</published>
    <updated>2009-06-11T13:40:55Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by schlick</title>
<content type="html">&lt;p&gt;Yep, same as Matt. When no db/sphinx/test directory exists beforehand, running the cucumber tests will fail. I had to manually perform rake ts:index &lt;span class=&quot;caps&quot;&gt;RAILS&lt;/span&gt;_ENV=test in order for this directory to be created and populated. I would&#8217;ve thought ThinkingSphinx::Configuration.instance.build would do it but it doesn&#8217;t appear to. Still, thanks for the great blog post &#8211; it was the solution I&#8217;ve been looking for!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Matt</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14657</id>
    <published>2009-06-08T23:41:12Z</published>
    <updated>2009-06-08T23:41:12Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Matt</title>
<content type="html">&lt;p&gt;Thanks! I actually had to run an index manually before it would start or stop my test sphinx. Anyway, got it working. :)&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Brandon</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14606</id>
    <published>2009-06-05T13:20:19Z</published>
    <updated>2009-06-05T13:20:19Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Brandon</title>
<content type="html">&lt;p&gt;Matt,  Sorry, in the process of getting this to work, I must have run &lt;code&gt;rake thinking_sphinx:configure RAILS_ENV=test&lt;/code&gt;, which would have generated the test config.  I deleted mine locally and I get the same error.  To fix it, add the following line in &lt;code&gt;env.rb&lt;/code&gt; right before calling &lt;code&gt;#start&lt;/code&gt;:&lt;/p&gt;


&lt;pre&gt;
ThinkingSphinx::Configuration.instance.build
&lt;/pre&gt;

	&lt;p&gt;I&#8217;ve updated the post to include this.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Matt</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14591</id>
    <published>2009-06-03T23:22:21Z</published>
    <updated>2009-06-03T23:22:21Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Matt</title>
<content type="html">&lt;p&gt;Thanks for the write up, this is something I&#8217;ve been trying to do for a while.&lt;/p&gt;


	&lt;p&gt;Unfortunately it says &#8220;Failed to start searchd daemon.&#8221; whenever I try to run my features. Did you have to change your sphinx config at all? Any other ideas?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Brandon</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14542</id>
    <published>2009-06-02T17:44:14Z</published>
    <updated>2009-06-02T17:44:14Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Brandon</title>
<content type="html">&lt;p&gt;Joe, thanks, I fixed the link.  I&#8217;ll leave it up to the maintainer of Thinking Sphinx to decide if he wants to pull any of it.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>Joe Van Dyk</name>
    </author>
    <id>tag:opensoul.org,2009-06-01:14492:14539</id>
    <published>2009-06-02T16:28:51Z</published>
    <updated>2009-06-02T16:28:51Z</updated>
    <category term="Code"/>
    <link href="http://opensoul.org/2009/6/1/cucumber-scenarios-that-depend-on-sphinx" rel="alternate" type="text/html"/>
    <title>Comment on 'Cucumber scenarios that depend on Sphinx' by Joe Van Dyk</title>
<content type="html">&lt;p&gt;The database_cleaner link is broken.&lt;/p&gt;


	&lt;p&gt;Would it be possible to put that code into ThinkingSphinx itself?  Perhaps it could run whenever it detects that cucumber is running?&lt;/p&gt;</content>  </entry>
</feed>
