Monday, April 12, 2010

Speed up Rails tests when using Compass

So here's a little tidbit.  When you're using Compass with Rails, check to see if it slowed down your tests.  I used test_benchmark, and saw that it increased my test times 3 fold.  I narrowed it down to the initializer/compass.rb files that gets loaded.  Tests should need to use Compass at all to make it work, and just wrap its contents, like so:

if RAILS_ENV != "test"
  require 'compass'
  # If you have any compass plugins, require them here.
  Compass.configuration.parse(File.join(RAILS_ROOT, "config", "compass.config"))
  Compass.configuration.environment = RAILS_ENV.to_sym
  Compass.configure_sass_plugin!
end

And that'll do it.  

I got too lazy to put this in a gist.  It'd be really nice if posterous let you edit gists in-place in their editor.

Posted via web from The Web and all that Jazz

No comments:

Post a Comment