Well it's a portal object and 99% of application functionalities rely on portal existing with its settings. Portal is changeable but it is not changed everywhere. My thought was that i always have that object in database and just change portal settings in tests where it is needed since now i'm inserting it before every test. Updating it on some places and reseting it after is by my thought much better for performance than inserting it for each test.
On Tuesday, August 21, 2018 at 12:23:10 PM UTC+2, Jon Rowe wrote: > > 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] <javascript:> > 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/c007b1af-8e13-4af0-9e88-dff0f29c4c11%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
