Different testing strategies have different trade offs, and which you
use depends largely on what's most important to you--i.e. is a fast
test suite more important, or one that has great test coverage?   That
said, here's what works well for me:

* In my unit specs (both model and controller), TS is mocked out.
* In my integration tests (using cucumber), I'm actually hitting
sphinx.

My assumption here is that TS is a well-tested library on its own, and
while hitting sphinx in my unit specs may increase my coverage, my
cucumber coverage is sufficient, and I don't really need to be hitting
sphinx in both suites.

> User.stubs(:search).returns(User.all)

Be careful about using a dynamic value such as User.all in your
stubbing--suddenly, you're coupling your tests to what's present in
your database, and you may unknowingly create a dependency such that
adding or removing a record from your fixtures causes this test to
fail.  Generally speaking, mocking and stubbing should use
deterministic values that don't change based on your global test set
up.

Myron

On Feb 8, 9:23 am, Maranga <[email protected]> wrote:
> Hi everybody,
> The application I'm working on uses extensively thinking sphinx and I
> have many doubts about the best testing strategy to use.
> After reading many posts on this group I've decided to stub out TS on
> functional tests, using something like this inside my tests:
>
> User.stubs(:search).returns(User.all)
>
> So now I have to do the real testing on TS: where would you put these
> tests? Do you think they belong the User class unit tests?
> I'm also having a hard time understanding how to index the data I'm
> creating on individual tests with factories. Could anybody show me a
> working example, possibly using the standard unit/functional rails
> test suite?
> Unfortunately I have never been using Cucumber: should I?
> Thanks for any help

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

Reply via email to