Using Jasminerice to test CoffeeScript in a Rails Engine
UPDATE: Use teaspoon now to integrate Jasmine with your Rails app and Rails engine.
So I looked under the hood of the gem and found that with a couple of fixes you can get it working with a Rails Engine.
Ideally I will create a pull request and have Jasminerice work for plain Rails apps and for Rails Engine. For now you can follow these instructions to get it working with your Engine. Please let me know if you find a nicer/simpler way to test your Rails Engines with Jasmine.
The main difference is that in a Rails Engine all your Rails classes and Java/CoffeeScript are namespaced and you need to tell Jasminerice to look in a few different places.
Enabling Jasminerice for you engines
So with a simple initialization change of your application you can start using Jasminerice to test your engine!
In your spec/dummy/config/routes.rb add the following to mount Jasminerice
if Rails.env.test? || Rails.env.development? mount Jasminerice::Engine => "/jasmine" get "/jasmine/:suite" => "jasminerice/spec#index" end
Then create the following initializer in config/initializers/jasminerice.rb
Of course don't forget to add the gem "jasminerice" to the development and test group of your Gemfile.
/* *= require application */
#= require jquery #= require jquery_ujs #= require jquery.ui.all #= require_tree . jasmine.getFixtures().fixturesPath = 'fixtures'
#= require my_engine/my_controller describe "AddRemoveController", -> it "exists", -> expect(1).toEqual(1) expect(MyEngine.MyController).not.toBeUndefined() it "has html", -> loadFixtures "an_html_file" addButton = $('article#subcontractors .add_fields') expect(addButton).not.toBeUndefined()
To view the results of all your tests: http://localhost:3000/jasmine
A few good resources to learn more about jasmine: