[LRUG] Same query, different results

Simon Coffey simon at tribesports.com
Mon Jan 23 08:29:36 PST 2012


Hi Jono,

On 23 January 2012 16:00, Jonathan <j.fantham at gmail.com> wrote:

>
> On 23 January 2012 15:53, Richard Taylor <richard at richt.co.uk> wrote:
> >
> > Is your Retailer created by the spec?  I think the tests are run in a
> > transaction that gets rolled back, so only the db session that created
> the
> > object will be able to see it, this would explain why you can't see it
> > anywhere else.



Yeah it is. It's created in a before(:each).
>
> Ok thanks, so I guess can't use transactional specs and I'll need to
> stick with fixtures for now. Pity!
>

Not necessarily - using something like the database_cleaner gem (
https://github.com/bmabey/database_cleaner) you can clean up after each
example using table truncation - there's an example configuration in the
README. My integration tests (cucumber, not rspec, but same diff) run quite
happily using factories and DatabaseCleaner with the truncation strategy.

Alternatively, there might be some way to force everything to use a shared
DB connection, but it's hard to say without knowing more about your setup.

Cheers,
Simon

-- 
Simon Coffey
Developer, Tribesports
simon at tribesports.com | 07960 004 857
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20120123/15e31791/attachment-0003.html>


More information about the Chat mailing list