jstorimer / spin

Spin speeds up your Rails testing workflow by preloading your Rails environment.

Home Page:http://jstorimer.github.com/spin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails 2 support

jstorimer opened this issue · comments

cc @mathieul

continued from #5

I've pushed some code to the 'rails2' branch to take care of this. If someone would test it out then I'll merge it to master.

I tested the branch rails2 with our big application, and it works great!

The Rails 2.3.5 application uses Ruby ree-1.8.7-2011.03, and the tests are written with test/unit. I use guard to start spin serve and trigger spin push.

For reference here's how I use guard with spin:

Gemfile

group :test do
  gem 'guard'
  gem 'guard-shell'
  gem 'spin', :git => 'git://github.com/jstorimer/spin.git', :branch => 'rails2'
end

Guardfile

fork do
  puts 'Starting spin server, please wait for the "Preloaded Rails env" message.'
  system 'spin serve -I./test'
end

guard 'shell' do
  watch(%r{^lib/(.+)\.rb$})             { |m| `spin push test/#{m[1]}_test.rb` }
  watch(%r{^test/.+_test\.rb$})         { |test| `spin push #{test}` }
  watch(%r{^app/models/(.+)\.rb$})      { |m| `spin push test/unit/#{m[1]}_test.rb` }
  watch(%r{^app/controllers/(.+)\.rb$}) { |m| `spin push test/functional/#{m[1]}_test.rb` }
end

To start TDD, open a terminal and run guard. Now any change you make to a test or a ruby file coupled to a test (according to regexp rules in Guardfile) will trigger spin push test/..., and the output of the spin server running the test will be displayed in this terminal.

I ran more of our 2.3 app tests using spin. As 'spin serve' was reporting loading the environment in less than 1 sec, I decided to test again running the same tests without using spin. They are taking about 20% more time to run when using rake (rake test:units TEST=test/units/....). And I timed the same test using only ruby this time (ruby -Itest test/unit/.....). And those are actually taking the same time than with spin.

So contrary to my first conclusion, it doesn't seem like spin loading boot.rb is actually us much. Not using rake for running single tests is what helps. So I don't think it is worth the trouble of making spin work with 2.3 rails apps after all. It is great for Rails 3.x, so we'll stick to using it for our other apps.

Closing until someone comes up with a better idea.

Hi all,

We published a gem today named Rails2Preload that attempts to resolve this issue. It uses Spin’s hook system to patch the Rails 2 initialization method, splitting it into two phases: preload and postload. Any feedback would be welcome.

Thanks!

@toddmazierski Thanks for taking the time to figure out how to preboot a Rails 2 app! With a few minor tweaks, we were able to get spring working with our Rails 2.3 app.

You're welcome, @lmarburger! Thanks for sharing that, you made my day. 😄