Skip to content

Instantly share code, notes, and snippets.

@AlexZeitler
Forked from michaelcox/SpecRunner.js
Created March 27, 2013 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexZeitler/5254716 to your computer and use it in GitHub Desktop.
Save AlexZeitler/5254716 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8"/>
<title>Backbone Tests</title>
<link rel="stylesheet" href="libs/mocha.css"/>
</head>
<body>
<div id="mocha"></div>
<script data-main="SpecRunner.js" src="/app/libs/require.js"></script>
</body>
</html>
define(function(require) {
var models = require('models');
describe('Models', function() {
describe('Sample Model', function() {
it('should default "urlRoot" property to "/api/samples"', function() {
var sample = new models.Sample();
sample.urlRoot.should.equal('/api/samples');
});
});
});
});
define(function(require) {
var Backbone = require('backbone');
var models = {};
models.Sample = Backbone.Model.extend({
urlRoot: '/api/samples'
});
return models;
});
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
},
shim: {
'underscore': {
exports: '_'
},
'jquery': {
exports: '$'
},
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'chai-jquery': ['jquery', 'chai']
},
urlArgs: 'bust=' + (new Date()).getTime()
});
require(['require', 'chai', 'chai-jquery', 'mocha', 'jquery'], function(require, chai, chaiJquery){
// Chai
var should = chai.should();
chai.use(chaiJquery);
/*globals mocha */
mocha.setup('bdd');
require([
'specs/model-test.js',
], function(require) {
mocha.run();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment