Interesting Things
- If you are testing with jasmine, it's a good idea to include your CSS files in the test runner. This prevents, for example, issues where you've hidden an element in the CSS and expect it to be visible in your JavaScript. If you are using Sass, then you should regenerate your CSS from the Sass before running the jasmine tests. The current version of haml-edge updates the sass command-line tool with an update command. On one of our client projects, we added the following to our jasmine_config.rb file:
def update_sass
puts "Updating sass files..."
rails_root = File.expand_path(File.dirname(__FILE__) + "/../../../")
sass_path = "#{rails_root}/vendor/bundler_gems/ruby/1.8/gems/haml-edge-2.*/bin/sass"
puts `#{sass_path} --update #{rails_root}/app/stylesheets:#{rails_root}/public/stylesheets/generated`
puts "done."
end
alias_method :old_start, :start
def start(*args)
update_sass
old_start(*args)
end
alias_method :old_start_server, :start_server
def start_server(*args)
update_sass
old_start_server *args
end
Sass provides a method for doing the same thing within ruby:
If you're running within your app container you won't need to configure anything, otherwise you'll need to set the
Sass::Plugin.optionsaccordingly first.Thanks, Chris!
FWIW, Jasmine, in most cases, will no longer have a jasmine_config.rb. New users would probably be best off adding functionality to the jasmine:ci or jasmine rake tasks that jasmine-ruby provides.