johnbintz/jasmine-headless-webkit — Issue #107: `JHW -l` not loading files in proper order
Author: wulftone
Created: 2012-01-10 23:52:26+00:00
State: open

I'm trying to get this gem working, but it seems to load my sprockets required files out of order. My app works using the `test_track` gem for jasmine testing, and also works using `capybara` and the webkit driver, and as a regular app in development mode or deployed to herkou--so I know sprockets is set up correctly!

However, when I set up JHW, I get the following errors:

Running `bundle exec jasmine-headless-webkit -c spec/javascripts/views/homefront/users/show_spec.js.coffee`
/usr/share/themes/Felicia/gtk-2.0/gtkrc:79: Murrine configuration option "gradients" is no longer supported and will be ignored.
ReferenceError: Can't find variable: jQuery
ReferenceError: Can't find variable: jQuery
ReferenceError: Can't find variable: Homefront
ReferenceError: Can't find variable: Homefront
ReferenceError: Can't find variable: Homefront
ReferenceError: Can't find variable: Homefront
ReferenceError: Can't find variable: Homefront
ReferenceError: Can't find variable: Homefront
TypeError: Result of expression 'i' [undefined] is not a function.
ReferenceError: Can't find variable: $
ReferenceError: Can't find variable: jQuery
ReferenceError: Can't find variable: jQuery
TypeError: Result of expression 'Homefront.Models.User' [undefined] is not a constructor.
TypeError: Result of expression 'Homefront.Models.HouseholdsUser' [undefined] is not a constructor.

Test ordering seed: --seed 5481

Which makes sense, since when I do a `jasmine-headless-webkit -l` command, I get the following:

/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-core-1.1.0/lib/jasmine-core/jasmine.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-core-1.1.0/lib/jasmine-core/jasmine-html.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-core-1.1.0/lib/jasmine-core/jasmine.css
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-headless-webkit-0.8.4/vendor/assets/javascripts/jasmine-extensions.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-headless-webkit-0.8.4/vendor/assets/javascripts/intense.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-headless-webkit-0.8.4/vendor/assets/javascripts/headless_reporter_result.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-headless-webkit-0.8.4/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-headless-webkit-0.8.4/vendor/assets/javascripts/jsDump.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-headless-webkit-0.8.4/vendor/assets/javascripts/beautify-html.js
/home/trevor/work/yc/app/assets/javascripts/toggle_disabled.js
/home/trevor/work/yc/app/assets/javascripts/underscore.js
/home/trevor/work/yc/app/assets/javascripts/backbone_link.js
/home/trevor/work/yc/app/assets/javascripts/models/homefront/relationship.js.coffee
/home/trevor/work/yc/app/assets/javascripts/models/homefront/household.js.coffee
/home/trevor/work/yc/app/assets/javascripts/models/homefront/account.js.coffee
/home/trevor/work/yc/app/assets/javascripts/models/homefront/households_user.js.coffee
/home/trevor/work/yc/app/assets/javascripts/models/homefront/user.js.coffee
/home/trevor/work/yc/app/assets/javascripts/models/homefront/invitation.js.coffee
/home/trevor/work/yc/app/assets/javascripts/backbone.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery_ujs.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-core-1.1.0/lib/jasmine-core/json2.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/backbone-rails-0.5.2/vendor/assets/javascripts/underscore.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/backbone-rails-0.5.2/vendor/assets/javascripts/backbone.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/rails-backbone-0.5.4/vendor/assets/javascripts/backbone_rails_sync.js
/home/trevor/work/yc/app/assets/javascripts/backbone-relational.js
/home/trevor/work/yc/app/assets/javascripts/homefront.js.coffee
/home/trevor/work/yc/app/assets/templates/homefront/index.jst.eco
...
/home/trevor/work/yc/app/assets/templates/relationships/index.jst.eco
/home/trevor/work/yc/app/assets/javascripts/backbone_base_view.js.coffee
/home/trevor/work/yc/app/assets/javascripts/backbone_rails_sync.js
/home/trevor/work/yc/app/assets/javascripts/helpers/toggle_disabled.js
/home/trevor/work/yc/app/assets/javascripts/json2.js
/home/trevor/work/yc/app/assets/javascripts/routers/homefront/home_router.js.coffee
/home/trevor/work/yc/app/assets/javascripts/routers/homefront/setup_router.js.coffee
/home/trevor/work/yc/app/assets/javascripts/sinon.js
/home/trevor/work/yc/app/assets/javascripts/underscore.string.js
/home/trevor/work/yc/app/assets/javascripts/views/homefront/index.js.coffee
...
/home/trevor/work/yc/app/assets/javascripts/views/relationships/index.js.coffee
/home/trevor/work/yc/app/assets/javascripts/application.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-spec-extras-0.0.2/vendor/assets/javascripts/jasmine-jquery.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-spec-extras-0.0.2/vendor/assets/javascripts/sinon.js
/home/trevor/.rvm/gems/ruby-1.9.2-p290/gems/jasmine-spec-extras-0.0.2/vendor/assets/javascripts/jasmine-sinon.js
/home/trevor/work/yc/spec/javascripts/helpers/spec_helper.js.coffee
/home/trevor/work/yc/spec/javascripts/views/homefront/users/show_spec.js.coffee

The problem is clearly that it's loading a couple of jQuery-dependent files and a few of my Backbone models before it loads their dependencies (jQuery, and homefront.js.coffee are the dependencies). Actually, looking at it closer, even if that's solved, it's still loading backbone.js way too late.

Here's my application.js

//= require jquery
//= require jquery_ujs
//= require json2
//= require underscore
//= require backbone
//= require backbone_rails_sync
//= require backbone_link
//= require backbone-relational
//= require homefront
//
//= require_tree ../templates
//= require_tree .
//= require_tree ./models
//= require_tree ./views
//= require_tree ./routers

This is the proper order of files I need... Any idea what's going on?

Thanks!