So that I may explore many wonderful recipes and see the meals in which they were served As someone interested in cooking I want to be able to easily explore this awesome site

Scenario: Exploring food categories (e.g. Italian) from the homepage # ./features/site.feature:31 Given 25 yummy meals # features/step_definitions/site.rb:1 And 50 Italian recipes # features/step_definitions/recipe_search.rb:131 And 10 Breakfast recipes # features/step_definitions/recipe_search.rb:131 When I view the site's homepage # features/step_definitions/site.rb:87 And I click the Italian category # features/step_definitions/site.rb:131 Then I should see 20 results # features/step_definitions/recipe_search.rb:260 expected following output to contain a <table td a/> tag:... <p class="no-results"> No results matched your search. Please refine your search </p>... (Spec::Expectations::ExpectationNotMetError) ./features/step_definitions/recipe_search.rb:261:in `/^I should see (\d+) results$/' ./features/site.feature:38:in `Then I should see 20 results' And I should see 2 pages of results # features/step_definitions/recipe_search.rb:264 When I click the site logo # features/step_definitions/site.rb:112 Then I should see the homepage # features/step_definitions/site.rb:163 And I click the Breakfast category # features/step_definitions/site.rb:131 Then I should see 10 results # features/step_definitions/recipe_search.rb:260 And I should see no more pages of results # features/step_definitions/site.rb:167

I am using couchdb-lucene to present a list of recipes in a given category (Italian, Vegetarian, etc.). The categories are presented as part of the master layout, which is why this particular scenario is part of the overall "site" feature. At any rate, to resolve this failure, I should only need to add categories to my couchdb-lucene design document:

If a recipe is both Italian and vegetarian, then it will have two entries in the tag_names array. I join them in the index function so that "italian vegetarian" will be added to the index (Lucene will tokenize into individual terms first). With that I ought to be done:

So that I may explore many wonderful recipes and see the meals in which they were served As someone interested in cooking I want to be able to easily explore this awesome site

Scenario: Exploring food categories (e.g. Italian) from the homepage # ./features/site.feature:31 Given 25 yummy meals # features/step_definitions/site.rb:1 And 50 Italian recipes # features/step_definitions/recipe_search.rb:131 And 10 Breakfast recipes # features/step_definitions/recipe_search.rb:131 When I view the site's homepage # features/step_definitions/site.rb:87 And I click the Italian category # features/step_definitions/site.rb:131 Then I should see 20 results # features/step_definitions/recipe_search.rb:260 expected following output to contain a <table td a/> tag:... <p class="no-results"> No results matched your search. Please refine your search </p>... (Spec::Expectations::ExpectationNotMetError) ./features/step_definitions/recipe_search.rb:261:in `/^I should see (\d+) results$/' ./features/site.feature:38:in `Then I should see 20 results' And I should see 2 pages of results # features/step_definitions/recipe_search.rb:264 When I click the site logo # features/step_definitions/site.rb:112 Then I should see the homepage # features/step_definitions/site.rb:163 And I click the Breakfast category # features/step_definitions/site.rb:131 Then I should see 10 results # features/step_definitions/recipe_search.rb:260 And I should see no more pages of results # features/step_definitions/site.rb:167

Bah! That is the exact same failure I had before. What's worse is that it is now taking over a minute to fail where before it was 5 seconds. I am sure that worked in couchdb-lucene 0.2, so what gives? Checking out the couchdb-lucene log, I find a whole bunch of:

For an array like rec['tag_names'], the typeof function should return "object", the constructor attribute should be "Array", and it ought to be an instance of Array. What I find is after re-running the Cucumber scenario is:

Something is going wrong, but I do not think that it in my code—especially since this same code worked with couchdb-lucene 0.2. I doubt I'll be able to figure a bad JSON array mapping into Spidermonkey (or couchdb-lucene—not sure where the problem really is). I will submit a bug report, but first... a workaround.

I may not have an Array here, but I do have an object. I can iterate over the properties in the object, which is an awful lot like treating it as an Array:

So that I may explore many wonderful recipes and see the meals in which they were served As someone interested in cooking I want to be able to easily explore this awesome site

Scenario: Exploring food categories (e.g. Italian) from the homepage # ./features/site.feature:31 Given 25 yummy meals # features/step_definitions/site.rb:1 And 50 Italian recipes # features/step_definitions/recipe_search.rb:131 And 10 Breakfast recipes # features/step_definitions/recipe_search.rb:131 When I view the site's homepage # features/step_definitions/site.rb:87 And I click the Italian category # features/step_definitions/site.rb:131 Then I should see 20 results # features/step_definitions/recipe_search.rb:260 And I should see 2 pages of results # features/step_definitions/recipe_search.rb:264 When I click the site logo # features/step_definitions/site.rb:112 Then I should see the homepage # features/step_definitions/site.rb:163 And I click the Breakfast category # features/step_definitions/site.rb:131 Then I should see 10 results # features/step_definitions/recipe_search.rb:260 And I should see no more pages of results # features/step_definitions/site.rb:167

1 scenario (1 passed)12 steps (12 passed)0m6.870s

After another quick fix, I am down to 3 failing scenarios—all are tied to a reduce for which I deservedly caught grief last year. I am not quite sure how to deal with that other than disabling the reduce limit in the CouchDB config. I will mull that over and tackle the solution tomorrow.