I need help figuring out why my rspec tests are slow.
I am running spork, guard and rspec. However, it seems like spork reinitializes the rails every time. I find it difficult to determine how to debug this problem. I suspect that some stone that I use causes this, but has no evidence.
I think this is a reboot:
- It takes the same amount of time to run inside spork or outside
I get this warning (associated with the SOLR gem) that I get when starting the rails server
Running all specifications
DEPARTMENT WARNING: InstanceMethods module inside ActiveSupport :: Concern will no longer turn on automatically. Please define instance methods directly in Sunspot :: Rails :: SolrInstrumentation. (called from /home/dougt/replyinline/config/environment.rbhaps)
Here is my spec_helper.rb
require 'rubygems' require 'spork'
Gemfile
source 'http://rubygems.org' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' # gem "less-rails", "~> 2.1.4" gem 'twitter-bootstrap-rails',"~> 2.0.3" end group :test do # Pretty printed test output gem 'spork-rails' gem 'rspec-rails', '2.8' gem 'guard-spork' gem 'rspec' gem 'growl' gem 'rb-fsevent' gem 'guard-spork' end group :development do gem 'guard' gem 'guard-rspec' gem 'turn', '~> 0.8.3', :require => false gem 'webrat', '0.7.3' gem 'therubyracer' gem 'progress_bar' gem 'sunspot_solr' gem 'minitest' gem 'rspec-rails', '2.8' end gem 'rails', '3.2.2' gem 'jquery-rails' gem 'pg' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'ruby-debug19', :require => 'ruby-debug' gem 'execjs' gem 'devise' gem "cancan" gem "oauth" gem "oauth2" gem "oauth-plugin", ">= 0.4.0.rc2" gem "autotest" gem "autotest-rails-pure" gem "autotest-notification" gem 'uuidtools' gem 'json' gem 'twitter' gem 'ZenTest', '4.6.0' gem 'mobylette' gem 'diff-lcs' gem 'twitter-text' gem 'chronic',:git => 'git://github.com/tarr11/chronic.git' gem 'sunspot_rails' gem 'delayed_job_active_record', "~> 0.3.2" gem 'delayed_task' gem 'codemirror-rails', "~> 2.22" gem 'thin' gem "paperclip", "~> 2.0" gem 'aws-sdk' gem 'aws-s3' gem 'newrelic_rpm' gem 'airbrake' gem 'factory_girl_rails', "~> 1.2" gem 'diff_match_patch' gem 'draper' gem "email_veracity", "~> 0.6.0"
Guardfile
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do watch('config/application.rb') watch('config/environment.rb') watch(%r{^config/environments/.+\.rb$}) watch(%r{^config/initializers/.+\.rb$}) watch('Gemfile') watch('Gemfile.lock') watch('spec/spec_helper.rb') { :rspec } watch('test/test_helper.rb') { :test_unit } watch(%r{features/support/}) { :cucumber } end guard 'rspec', :version => 2 do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } # Rails example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch('config/routes.rb') { "spec/routing" } watch('app/controllers/application_controller.rb') { "spec/controllers" } # Capybara request specs watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } end
Security Terminal Output
dougt@dougt-ThinkPad-W520 ~/project $ bundle exec guard Guard uses NotifySend to send notifications. Guard is now watching at '/home/dougt/project' Starting Spork for RSpec Using RSpec, Rails Preloading Rails environment Loading Spork.prefork block... DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in Sunspot::Rails::SolrInstrumentation instead. (called from <top (required)> at /home/dougt/project/config/environment.rb:5) Spork is ready and listening on 8989! Spork server for RSpec successfully started Guard::RSpec is running, with RSpec 2! Running all specs DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in Sunspot::Rails::SolrInstrumentation instead. (called from <top (required)> at /home/dougt/project/config/environment.rb:5) /home/dougt/project/app/models/dropbox_token.rb:7: warning: already initialized constant ACCESS_TYPE /home/dougt/project/app/models/dropbox_token.rb:9: warning: already initialized constant DROPBOX_SETTINGS *.........**.....................***....***.....................***......*......................* Pending: UserMailer add some examples to (or delete) /home/dougt/project/spec/mailers/user_mailer_spec.rb