Jasmine won't load javascript files from asset

2019-04-23 05:05发布

问题:

I'm developing a gem and I've installed Jasmine https://github.com/pivotal/jasmine-gem/

All of my required JS files are in my manifest file at app/assets/javascripts/application.js

//= require underscore
//= require backbone

//= require_tree .//vendor
//= require_tree .//custom

//= require_tree .//templates
//= require_tree .//models
//= require_tree .//collections
//= require_tree .//views

And my jasmine.yml file references that:

src_files:
  - 'app/assets/javascripts/application.js'

But none of the files specified in it load. Anyone know why? I'm using the latest, Jasmine 1.3.2, which is supposed to support the asset pipeline so that you don't need to use something like jasmine-rails. Any thoughts?

回答1:

In your jasmine.yml the path should be 'assets/application.js'. If you're still having trouble, make sure you have your jasmine gem under both development and test groups in your Gemfile, as specified in the instructions on https://github.com/pivotal/jasmine-gem:

group :development, :test do
  gem 'jasmine'
end


回答2:

If you are using Rails 4 there is bug in version 1.3.2 where is it checking config.assets.enabled which no longer is defined in Rails 4.

The following worked for me. gem 'jasmine', "~> 2.0.0.rc4"

This is the ticket that talks about the issue. https://github.com/pivotal/jasmine-gem/pull/177