You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jfirebaugh edited this page Feb 18, 2013
·
2 revisions
An example of how to use RequireJS with Konacha:
app/assets/javascripts/sum.js:
define(function() {
return function (a, b) { return a + b; };
});
spec/javascripts/sum_spec.js:
//= require require
require.config({baseUrl: "/assets"});
describe('sum', function () {
var sum;
before(function (done) {
require(['sum'], function (m) {
sum = m;
done();
}, done);
});
it('adds two numbers', function () {
expect(sum(2, 2)).to.equal(4);
});
});
Yes, you're using the asset pipeline, in tests only, for one require directive. All that does, however, is trigger injection of the <script src="/assets/require.js"> tag that kicks off RequireJS, so it seems quite reasonable to me.