Hi Uros

When I said to hardcode them, I meant to do it in the application, if that data 
never changes then why is it in the database? If it does change then why isn’t 
it changing in your tests? If its something like a multi-tenant situation then 
why doesn’t each type of object just create its own tenant?

Unfortunately I suspect you are feeling the effect of having a large amount of 
coupled code so you are not going to be able to speed up these tests without 
uncoupling it so it doesn’t need such test data all the time.

The only further suggestion I have here is to remove the truncation cleanup 
calls, if you’re using transactional cleaning on tests you shouldn’t need the 
additional truncation ones.

Cheers
Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk

On 21 August 2018 at 11:08, Uros Certic wrote:
> Hi Jon, thanks for the info.
>
> Problem is that functions that we are trying to write tests for have a lot of 
> database calls for the records i mentioned above so just hardcoding them or 
> mocking them is not gonna work. Now i know that this is not the best practise 
> but code is old and refactoring it is currently not possible...so i'm trying 
> to work on speeding up tests. Also i tried with excluding tables but it 
> created some other issues in some tests.
>
> My current spec config looks something like this...
>
> config.use_transactional_fixtures = true
>
>
>
> config .before(:all) do
>
> DatabaseCleaner.clean_with(:truncation)
>
> end
>
>
>
> config .before(:each) do
>
> DatabaseCleaner.strategy = :
> transaction
>
> end
>
>
>
> config .before(:each) do
>
> DatabaseCleaner.
> start
>
> end
>
>
>
> config .after(:each) do
>
> DatabaseCleaner.
> clean
>
> end
>
>
> Not sure on logic behind this since it was not my setup but do you think this 
> can be improved and for the problem above do you maybe have some other 
> solution?
>
> Cheers,
> Uros
>
> On Tuesday, August 21, 2018 at 11:50:40 AM UTC+2, Jon Rowe wrote:

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/dejalu-192-b68dce49-b159-4b13-8204-6291aacf4cb9%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to