bensheldon/panlexicon

Ensure searched terms are included in result set

bensheldon opened this issue · 4 comments

For example, searching for 'cat, Siamese' with MAX_WORDS=2 will not include 'Siamese'

becw commented

I just searched for 'apple, orange' with MAX_WORDS=2 and got mulberry pomegranate, which was pretty awesome.

Rad. I would suggest writing a test that fails for this, and then fixing it. TDD ftw.

On Sat, Nov 22, 2014 at 6:56 PM, becw notifications@github.com wrote:

I just searched for 'apple, orange' with MAX_WORDS=2 and got mulberry pomegranate, which was pretty awesome.

Reply to this email directly or view it on GitHub:
#5 (comment)

becw commented

I'm not sure what the test case would be, given that the example relies on MAX_WORDS=2.

In the spec for the Search#results method, we can add a new it block that looks something like this:

it 'always includes the searched terms, regardless of MAX_WORDS' do
  stub_const('Search::MAX_WORDS', 1)

  result_names = search.results.map(&:name)
  expect(result_names).to include('lion', 'tiger')
end

(these specs can be a little confusing because the search variable is declared by the let() method at the top of the first describe block)