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 QT with homebrew. (Full disclosure: upon running
brew update, I needed to
git stash in
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)
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 end gem 'guard-rails-assets' gem 'guard-jasmine-headless-webkit' end
This will create a little structure, most importantly your
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
Many thanks to John Bintz for making jasmine-headless-webkit, it's a wonderful tool.