开发者

Autotest responds slowly with Spork and Rspec under Rails 3.0.9

It's all working, but slowly.

I know that Spork is working, because rspec spec/ produces a response in under two seconds, and I know Autotest is working, since it eventually produces an appropriate Growl notification when I make a change to the controller code. The problem is that Autotest is taking too long to respond: about 16 seconds. Please help me figure out what's going wrong.

I'm new to Rails, and following Michael Hartl's Rails 3 Tutorial.

Platform:   Mac OS X 10.5.8
            Xcode 3.1.4
Ruby:       v. 1.9.2 p180  (with RVM)
Rails:      v. 3.0.9

For what it's worth, I installed Autotest and Spork using Bundler, and call them (each under its own terminal window tab) using bundle exec spork and bundle exec autotest. spork (without the "bundle exec") also runs fine, but autotest (without the "bundle exec") produces a "command not found开发者_开发技巧" error message.

My project's Gemfile (drawn from Hartl's tutorial book and video):

source 'http://rubygems.org'

gem 'rails', '3.0.9'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'

group :development do
  gem 'rspec-rails', '2.6.1'
  gem 'annotate', '2.4.0'
  gem 'faker', '0.3.1'
end

group :test do
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.1'
  gem 'spork', '0.9.0.rc8'
  gem 'autotest', '4.4.6'
  gem 'autotest-rails-pure', '4.1.2'
  gem 'autotest-fsevent', '0.2.4'
  gem 'autotest-growl', '0.2.9'
  gem 'factory_girl_rails', '1.0'
end

My project's .autotest file (also drawn from Hartl):

require 'autotest/growl'
require 'autotest/fsevent'
Autotest.add_hook :initialize do |autotest|
  autotest.add_mapping(/^spec\/requests\/.*_spec\.rb$/) do
    autotest.files_matching(/^spec\/requests\/.*_spec\.rb$/)
  end  
end

What happens:

When I save a change to one of my controller.rb files (or controller_spec.rb files), about 8 seconds elapse before there is any activity on the autotest terminal tab - which, at this point, is simply a row of hyphens preceded and followed by some empty lines. About 7 seconds later, the autotest tab displays the following message:

/Users/jlee/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -rrubygems -S /Users/jlee/rails_projects/sample_app_jbl/autotest/ruby/1.9.1/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/jlee/rails_projects/sample_app_jbl/spec/controllers/pages_controller_spec.rb'

Which is followed almost immediately by activity on spork's terminal tab, and the expected results of the test in all terminal windows and in a growl notification. So it's all working, just S-L-O-W-L-Y! I'm eager for suggestions about how to cut the first fifteen seconds out of autotest's response.

8/7/2011


Try adding --drb to the .rspec file at the root of your project: http://maxjustus.tumblr.com/post/1322305832/rspec-2-rails-3-autotest-and-spork

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜