Skip to content

Migrating from Jasminerice

Mike Pack edited this page May 22, 2015 · 9 revisions

The Jasminerice project is no longer being maintained by it's creator, which is a bummer. I've contributed to the project to keep it alive, but until someone has access to release the gem it's difficult to properly maintain releases, bug fixes, and dependency updates.

Because of this I would encourage people using Jasminerice to migrate to another runner for future and potentially current projects.

This page provides migration steps for Teaspoon, and at the bottom provides a list of alternative projects that might be useful.

While migration is fairly painless your results may vary.

Migration Steps

  1. Remove Jasminerice from your Gemfile and delete the initializer (config/initializers/jasminerice.rb).
  2. Add Teaspoon to your Gemfile with gem "teaspoon-jasmine" and install it with rails g teaspoon:install
  3. Rename spec/javascripts/spec.js to spec/javascripts/spec_helper.js (or .js.coffee, etc.)

This is where it gets interesting. So, Teaspoon prefers that you name your files a specific way (filename_spec.js), while Jasminerice uses a manifest approach (requiring all your spec files from spec.js).

While you can use a manifest approach with Teaspoon, you lose some of the really cool features -- like running a single file instead of your entire suite.. Read on based on what you'd like to do.

I'd prefer to utilize a better testing setup.

Awesome! You'll just need to make sure your spec files are named properly (eg. filename_spec.js -- or js.coffee etc.)

Update your spec_helper to not require all the specs.. by default this is a require_tree . directive, but you may have changed it.

If you're using jasmine-jquery you'll need to require it in your spec_helper (the fixture path will be set for you automatically).

//= require support/jasmine-jquery

Browse to /teaspoon instead of /jasmine.

I don't care about cool features.

That's cool, you'll just need to adjust your configuration a bit. Open up config/initializers/teaspoon.rb and change the configuration for the default suite to this:

config.suite do |suite|
  suite.matcher = nil
end

Browse to /teaspoon instead of /jasmine.. or if you'd rather, you can update the configuration further.

config.mount_at = "/jasmine"

If you're using jasmine-jquery you'll have to require it in your spec_helper (the fixture path will be set for you automatically).

//= require support/jasmine-jquery

Using Fixtures

When migrating from Jasminerice, you may have to deal with a change in syntax involving fixtures. You no longer need preloadFixtures() calls, and you should change loadFixtures to fixture.load in all of your specs.

Alternate Projects

Here's a list of alternative projects that you might want to check out as well: