Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7687173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:38:42+00:00 2026-05-31T19:38:42+00:00

I need help figuring out why my rspec tests are running slowly. I am

  • 0

I need help figuring out why my rspec tests are running slowly.

I am running spork, guard, and rspec. However, it appears that spork is re-initializing rails each time. I am having a difficult time figuring out how to debug this issue. I suspect some gem I am using is causing this but have no proof.

The reason I think it is reloading is:

  • It takes the same amount of time to run inside of spork or outside
  • I get this warning (related to the SOLR gem) that I get when I run
    rails server

    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 at /home/dougt/replyinline/config/environment.rb:5)


Here is my spec_helper.rb

require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

Spork.prefork do
  # Loading more in this block will cause your tests to run faster. However,
  # if you change any configuration or code from libraries loaded here, you'll
  # need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'

  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|
    # == Mock Framework
    #
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
    #
    # config.mock_with :mocha
    # config.mock_with :flexmock
    # config.mock_with :rr
    config.mock_with :rspec

    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
    config.fixture_path = "#{::Rails.root}/spec/fixtures"

    # If you're not using ActiveRecord, or you'd prefer not to run each of your
    # examples within a transaction, remove the following line or assign false
    # instead of true.
    config.use_transactional_fixtures = true
    config.include Devise::TestHelpers, :type => :view

    #https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3-(and-rspec)
    config.extend ControllerMacros, :type => :controller
    config.extend ControllerMacros, :type => :helper
    config.extend ControllerMacros, :type => :view

  end
end

Spork.each_run do
  # This code will be run each time you run your specs.
  #https://github.com/sporkrb/spork/issues/37
#   silence_warnings do
#      Dir["#{Rails.root}/app/models/**/*.rb"].each {|f| load f}
#  end
#  load "#{Rails.root}/config/routes.rb"
#  Dir["#{Rails.root}/app/**/*.rb"].each {|f| load f}

end

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

Guard 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
    # No reason given
    # ./spec/mailers/user_mailer_spec.rb:4
  PersonNote add some examples to (or delete) /home/dougt/project/spec/models/person_note_spec.rb
    # No reason given
    # ./spec/models/person_note_spec.rb:4
  Task add some examples to (or delete) /home/dougt/project/spec/models/task_spec.rb
    # No reason given
    # ./spec/models/task_spec.rb:4
  Alert add some examples to (or delete) /home/dougt/project/spec/models/alert_spec.rb
    # No reason given
    # ./spec/models/alert_spec.rb:4
  Slide add some examples to (or delete) /home/dougt/project/spec/models/slide_spec.rb
    # No reason given
    # ./spec/models/slide_spec.rb:4
  BetaTester add some examples to (or delete) /home/dougt/project/spec/models/beta_tester_spec.rb
    # No reason given
    # ./spec/models/beta_tester_spec.rb:4
  SlideContent add some examples to (or delete) /home/dougt/project/spec/models/slide_content_spec.rb
    # No reason given
    # ./spec/models/slide_content_spec.rb:4
  SharedFile add some examples to (or delete) /home/dougt/project/spec/models/shared_file_spec.rb
    # No reason given
    # ./spec/models/shared_file_spec.rb:4
  FileActivity add some examples to (or delete) /home/dougt/project/spec/models/file_activity_spec.rb
    # No reason given
    # ./spec/models/file_activity_spec.rb:4
  EmailHelper add some examples to (or delete) /home/dougt/project/spec/helpers/email_helper_spec.rb
    # No reason given
    # ./spec/helpers/email_helper_spec.rb:14
  TodoLinesHelper add some examples to (or delete) /home/dougt/project/spec/helpers/todo_lines_helper_spec.rb
    # No reason given
    # ./spec/helpers/todo_lines_helper_spec.rb:14
  UserHelper add some examples to (or delete) /home/dougt/project/spec/helpers/user_helper_spec.rb
    # No reason given
    # ./spec/helpers/user_helper_spec.rb:14
  TasksHelper add some examples to (or delete) /home/dougt/project/spec/helpers/tasks_helper_spec.rb
    # No reason given
    # ./spec/helpers/tasks_helper_spec.rb:14
  todo_lines/show.html.erb add some examples to (or delete) /home/dougt/project/spec/views/todo_lines/show.html.erb_spec.rb
    # No reason given
    # ./spec/views/todo_lines/show.html.erb_spec.rb:4

Finished in 7.71 seconds
Running: spec/models/todo_file_spec.rb
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
.....................

Finished in 3.05 seconds
21 examples, 0 failures
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:38:44+00:00Added an answer on May 31, 2026 at 7:38 pm

    You can profile spork and use the results to require stuff in the prefork block

    http://www.opinionatedprogrammer.com/2011/02/profiling-spork-for-faster-start-up-time/

    There is also an issue with Devise and possibly other gems calling reload, these methods can be trapped by adding the following to your spec_helper prefork block:

      ...
      ENV["RAILS_ENV"] ||= 'test'      
      # For Devise
      require "rails/application"
      Spork.trap_method(Rails::Application, :reload_routes!)
      Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
      ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help figuring out some regular expressions. I'm running the dig command and
I need help figuring out how to convert data that comes in from a
I need help figuring out bits of code. I need a function that loads
I need help figuring out how to change out the view in my application.
So I've got json-framework up and running on my project, but need help figuring
I need help figuring out how to display the contents of an NSArray into
I need help figuring out how to create a cell like the one representing
Need help in figuring out, why the downloaded file size is 0 bytes? On
I need help figuring out why I am getting a segmentation fault here. I
I need help on figuring out how to create a repository on github to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.