Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

103 lines (66 sloc) 4.111 kB

This is a skeleton app demonstrating jasmine-headless-webkit. Be sure to check out its page for detailed instructions.

Check this out if you want to:

  • write Jasmine specs
  • use CoffeeScript
  • leverage the asset pipeline in Rails 3.1
  • run specs headless & quickly enough to remove browser-refreshing from your workflow
  • (optional) getting growl notifications via Guard as your specs run


This was put together running Mac OS X Lion (10.7). I'm sure the details will differ slightly on other platforms.

Install XCode & Growl.

Install QT with homebrew. (Full disclosure: upon running brew update, I needed to git stash in /usr/local then git pull to get the latest recipes.)

brew update
brew install qt

Try it out

Once you've cloned this repository and changed into the directory, you should be able to run the Jasmine specs like so:

bundle install
bundle exec guard

When you run guard, it first compiles your assets, run your specs and then monitors for changes.

Note: if you don't care for the Growl, make sure you remove growl_notify from the Gemfile to prevent exceptions.

Running specs in your browser

If you'd like to run your specs in a browser, which is obviously very helpful when debugging, you can do so by visiting http://localhost:3000/jasmine.

The browser runner is generated by a rails engine by a jasmine-rails gem (which I'm hoping to also add some generator magic to)

The play-by-play

If you're looking to recreate a similar setup for your existing project, here are most of the steps I took.


Added to your Gemfile:

group :test, :development do
  gem 'jasmine-rails'

  if RUBY_PLATFORM =~ /darwin/i
    gem 'growl_notify'
    gem 'rb-fsevent', :require => false 
  gem 'guard-rails-assets'
  gem 'guard-jasmine-headless-webkit'

Jasmine config

Next, Run:

jasmine init

This will create a little structure, most importantly your spec/javascripts/support/jasmine.yml configuration file. You can safely remove lib/tasks/jasmine.rake, though.

Then, update your jasmine.yml file to look for CoffeeScript in the assets directories. Mine looks something like this.

  - "vendor/**/*.{js,coffee}"
  - "lib/**/*.{js,coffee}"
  - "public/**/*.{js,coffee}"
  - "helpers/**/*.{js,coffee}"
  - "**/*[Ss]pec.{js,coffee}"
spec_dir: spec/javascripts


I set guard up by running

bundle exec guard init rails-assets
bundle exec jasmine-headless-webkit

And changed these lines in my Guardfile to monitor all of my assets directories (under app, lib, and vendor):

guard 'rails-assets' do

guard 'jasmine-headless-webkit' do
  watch(%r{^.*/assets/javascripts/(.*)\.(js|coffee)$}) { |m| newest_js_file(spec_location % m[1]) }


Many thanks to John Bintz for making jasmine-headless-webkit, it's a wonderful tool.

Jump to Line
Something went wrong with that request. Please try again.