[LRUG] Same query, different results

Glenn Gillen glenn at rubypond.com
Mon Jan 23 08:40:50 PST 2012


Have you tried running putting the Postgres db on a RAM disk to speed it up? 

G

- from my mobile, excuse the spellnig

On 23 Jan 2012, at 08:34, Jonathan <j.fantham at gmail.com> wrote:

> Yeah I've actually just started changing the tests to use that, it's a
> bit slow because we have a lot of tables in our database (so cascading
> truncations spread far and wide) but it works and I plan on making the
> normal specs use transactions which is a step in the right direction.
> Thanks for the tip though, it seems like the best idea I've come
> across!
> 
> On 23 January 2012 16:29, Simon Coffey <simon at tribesports.com> wrote:
>> 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
>> 
>> _______________________________________________
>> Chat mailing list
>> Chat at lists.lrug.org
>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>> 
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org



More information about the Chat mailing list