public
Created

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
******* test/runner.html
 
<!DOCTYPE html>
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" type="text/css" href="../test/jasmine/lib/jasmine-1.2.0/jasmine.css">
<script src="../js/libs/require/require.js" data-main="SpecRunner"></script>
</head>
<body>
<div id="sandbox" style="overflow: hidden; height: 1px;"></div>
</body>
</html>
 
 
 
****** test/SpecRunner.js
 
require.config({
baseUrl: "../js/",
urlArgs: 'cb=' + Math.random(),
paths: {
jquery: 'libs/jquery/jquery-1.8.2.min',
underscore: 'libs/underscore/amd-js/underscore-min',
backbone: 'libs/backbone/amd-js/backbone-min',
'backbone.localStorage': 'libs/backbone/backbone.localStorage',
jasmine: '../test/jasmine/lib/jasmine-1.2.0/jasmine',
'jasmine-html': '../test/jasmine/lib/jasmine-1.2.0/jasmine-html',
spec: '../test/spec/',
cs: 'libs/require/cs',
hbs: 'libs/require/hbs',
handlebars: 'libs/require/Handlebars',
i18nprecompile: 'libs/hbs/i18nprecompile',
json2: 'libs/hbs/json2',
coffeescript : 'coffee-script'
},
hbs : {
templateExtension : 'html',
disableI18n : false
},
shim: {
underscore: {
exports: "_"
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backbone.localStorage': {
deps: ['backbone'],
exports: 'Backbone'
},
jasmine: {
exports: 'jasmine'
},
'jasmine-html': {
deps: ['jasmine'],
exports: 'jasmine'
}
}
});
 
 
window.store = "TestStore"; // override local storage store name - for testing
 
require(['underscore', 'jquery', 'jasmine-html' ], function(_, $, jasmine ){
 
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
 
var htmlReporter = new jasmine.HtmlReporter();
 
jasmineEnv.addReporter(htmlReporter);
 
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
 
var specs = [];
specs.push('cs!spec/views/loginSpec.spec');
 
$(function(){
require(specs, function(){
jasmineEnv.execute();
});
});
 
});
 
**** test/spec/views/loginSpec.spec.coffee
 
 
define [ 'cs!models/user'
, 'cs!views/login'
], (User, LoginView) ->
describe 'View :: Login', ->
it 'uses User', ->
expect(User).toBeDefined()
 
it 'uses LoginView', ->
expect(LoginView).toBeDefined()
 
it 'passes 2 + 2', ->
expect(2+2).toEqual(4)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.