Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
Standup 2/11/2010: Sass with Jasmine

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

Comments
  1. Sass provides a method for doing the same thing within ruby:

    Sass::Plugin.update_stylesheets

    If you’re running within your app container you won’t need to configure anything, otherwise you’ll need to set the `Sass::Plugin.options` accordingly first.

  2. Andrew Cantino says:

    Thanks, Chris!

  3. Rajan Agaskar says:

    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.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *