I know there is a way to know which specs are taking the most time, but my doubt is about the loading of the RSpec. The specs itself are not taking too much time, but the load is.
There is a way to discover that?
I am working on a Rails' legacy code and I don't know which gems could be affecting it.
For anyone who comes here, the problem was that the RSpec was truncating every time I ran the tests.
I discovered it by checking the log while it was starting (tail -f log/test.log
).
To solve that, I used the database_cleaner gem and configured it with :transaction
as the clean strategy.
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
spec_helper.rb
, but the tables keeps truncating as for log/test.log
file. Am I missing something? –
Avrilavrit Could be app-specific (amount of Gems to load for instance). To speed up Rspec load time significantly you can use spring-commands-rspec which implement the rspec command for Spring (Rails application preloader), as such:
In your gemfile, add:
gem 'spring-commands-rspec', group: :development
then run: bundle install
, and finally:
bundle exec spring binstub rspec
Run Rspec before and after this procedure, you should see a huge improvement.
More info here:
https://github.com/jonleighton/spring-commands-rspec https://schwad.github.io/ruby/rails/testing/2017/08/14/50-times-faster-rspec-loading.html https://www.netguru.com/blog/9-ways-to-speed-up-your-rspec-tests
spring stop
at the end could be helpful to restart Spring! –
Wittgenstein © 2022 - 2024 — McMap. All rights reserved.