using jasmine without rails

Assume you have, like I did, a ruby gem that contains some javascript you want to test standalone. First you need to install the jasmine-gem. You have two options:

  • either you use your gemspec to drive your bundler gemfile, so just add it to your developement dependencies
  • I am still using jeweler, so I use a normal Gemfile, which jeweler parses to populate my gemspec with. Personally I find this much easier, and my workflow is much closer to any ruby development for me, this way If you have a rails-project, starting with jasmine is easy, and takes three easy steps: [bash] # first add jasmine to Gemfile, and then bundle install rails g jasmine:install rake jasmine [/bash] Inside your gem or simple ruby-project it is equally simple, just type [bash] jasmine init rake jasmine [/bash] Now you can need to edit the jasmine.yml to make sure it is running your tests and your code, instead of the example code. In my case I had to change only one line: [ruby] src_files: - app/assets/javascripts/**/*.js [/ruby] Happy testing :) Some interesting links to help you with jasmine:
  • a very interesting slideshow
  • jasmine homepage

Add comment

Recent comments