Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rspec takes too long to load

I am using Rspec with my Rails 3.2.11 app. I have installed and set up spork. I use datamapper as ORM.

Yet when spork is running, a running a single test takes more than a minute. Even if the test being run is empty. Something is surely wrong. But I cannot figure out what exactly.

My test_spec is as this:

require "spec_helper"
require "cancan/matchers"

describe User do
end

My spec helper file can be found here: https://gist.github.com/4593609

When I time the rspec:

➜  books git:(dev) ✗ time rspec --drb spec/models/test_spec.rb
No examples found.


Finished in 1 minute 51.08 seconds
0 examples, 0 failures
rspec --drb spec/models/test_spec.rb  1.49s user 0.04s system 1% cpu 1:52.94 total

Spork Log:

➜  books git:(dev) ✗ spork
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Spork is ready and listening on 8989!
Running tests with args ["spec/models/test_spec.rb"]...
Done.

Running tests with args ["spec/models/test_spec.rb"]...
Done.

This is for an empty spec. It takes more time for specs with lots of examples. What can be taking so long for it to run ?

like image 492
arkiver Avatar asked Oct 27 '25 08:10

arkiver


1 Answers

Look at your test.log when running the tests , probably the database setup is done for every test and it takes up the time.

tail -f log/test.log when running the test

like image 174
srih4ri Avatar answered Oct 28 '25 23:10

srih4ri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!