testdouble / jasmine-rails

A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
http://rubygems.org/gems/jasmine-rails
MIT License
378 stars 154 forks source link

Add support for sprockets `stub` directive #179

Open mattduggan opened 8 years ago

mattduggan commented 8 years ago

Using rails v4.2.2, sprockets v3.4.0, sprockets-rails v2.3.3, jasmine-rails v0.12.2

In my application.js, I'm requiring a custom build of lodash (2.4.1) for compatibility with underscore/backbone. The app imports widgets, through Bower and bower-rails setup, which require lodash (3). To force the app to use 2.4.1, I've stub-bed them out after the first require.

/** application.js */
// include from vendor/assets/javascripts/
//= require lodash-2.4.1.custom
// ignore from vendor/assets/bower_components
//= stub lodash/lodash

/** require widget.rails */
//= require lodash/lodash
//= require foo/bar

The app site is behaving as expected and not including lodash 3, but Jasmine spec runner is, causing specs to fail. I can verify that it is exclusive to lodash and the require call, no other assets are getting included extraneously.

/** jasmine.yml */
src_dir: "app/assets/javascripts"
css_dir: "app/assets/stylesheets"
src_files:
 - "application.{js.coffee,js,coffee}"

helpers:
  - "helpers/**/*.{js.coffee,js,coffee}"

spec_dir: spec/javascripts
spec_files:
  - "**/*[Ss]pec.{js.coffee,js,coffee}"

tmp_dir: "tmp/jasmine"
searls commented 8 years ago

Cool. I wasn't aware of stub -- I assume that's a newer sprockets feature? In any case, a PR that investigates this and fixes it to work the same as the production manifest would be welcome

mattduggan commented 8 years ago

@searls I'll see what I can come up with. And yes! stub was introduced in the newer versions of sprockets.