Add missing deps, jasmine is mostly working; the specs aren't committed
yet, tho.
Showing
6 changed files
with
107 additions
and
2 deletions
... | @@ -50,4 +50,88 @@ module.exports = function(grunt) { | ... | @@ -50,4 +50,88 @@ module.exports = function(grunt) { |
50 | 50 | ||
51 | var montyPython = require('grunt-monty-python')(grunt); | 51 | var montyPython = require('grunt-monty-python')(grunt); |
52 | montyPython.createConfig(config); | 52 | montyPython.createConfig(config); |
53 | |||
54 | var _ = require('lodash'); | ||
55 | |||
56 | var jasmineRequirejsTemplateOptions = function(withInstanbul) { | ||
57 | /* global requirejs */ | ||
58 | var callback; | ||
59 | if (withInstanbul) { | ||
60 | callback = function() { | ||
61 | var oldLoad = requirejs.load; | ||
62 | requirejs.load = function (context, moduleName, url) { | ||
63 | //console.log('context=' + JSON.stringify(arguments), 'moduleName=' + moduleName, 'url=' + url); | ||
64 | var parts = url.split('/'); | ||
65 | for (var i = 0; i < parts.length; ) { | ||
66 | var part = parts[i]; | ||
67 | if (part === '.') { | ||
68 | parts.splice(i, 1); | ||
69 | } else if (part === '') { | ||
70 | parts.splice(i, 1); | ||
71 | } else if (part === '..') { | ||
72 | if (i > 0) { | ||
73 | i--; | ||
74 | parts.splice(i, 2); | ||
75 | } else { | ||
76 | parts.splice(i, 1); | ||
77 | } | ||
78 | } else { | ||
79 | i++; | ||
80 | } | ||
81 | } | ||
82 | url = parts.join('/'); | ||
83 | if (url.indexOf('src/scripts/') === 0) { | ||
84 | url = './.grunt/grunt-contrib-jasmine/' + url; | ||
85 | } | ||
86 | if (url.indexOf('test/specs/') === 0) { | ||
87 | url = './.grunt/grunt-contrib-jasmine/' + url; | ||
88 | } | ||
89 | //console.log('url=' + url); | ||
90 | return oldLoad.apply(this, [context, moduleName, url]); | ||
91 | }; | ||
92 | }; | ||
93 | } | ||
94 | return { | ||
95 | requireConfigFile: 'src/scripts/config.js', | ||
96 | requireConfig: { | ||
97 | baseUrl: 'src/scripts', | ||
98 | callback: callback | ||
99 | } | ||
100 | }; | ||
101 | }; | ||
102 | |||
103 | var jasmineInstanbulTemplateOptions = function(template, nestedOptions) { | ||
104 | return { | ||
105 | coverage: 'bin/coverage/coverage.json', | ||
106 | report: 'bin/coverage', | ||
107 | replace: false, | ||
108 | template: template, | ||
109 | templateOptions: nestedOptions | ||
110 | }; | ||
111 | }; | ||
112 | |||
113 | var jasmineOptions = function(withCoverage, options) { | ||
114 | var defaultOptions = {}; | ||
115 | defaultOptions.template = require('grunt-template-jasmine-requirejs'); | ||
116 | defaultOptions.templateOptions = jasmineRequirejsTemplateOptions(withCoverage); | ||
117 | if (withCoverage) { | ||
118 | defaultOptions.templateOptions = jasmineInstanbulTemplateOptions(defaultOptions.template, defaultOptions.templateOptions); | ||
119 | defaultOptions.template = require('grunt-template-jasmine-istanbul'); | ||
120 | } | ||
121 | return _.extend(defaultOptions, options); | ||
122 | }; | ||
123 | |||
124 | grunt.initConfig({ | ||
125 | jasmine: { | ||
126 | all: { | ||
127 | src: [ | ||
128 | 'src/scripts/{,**/}*.js', | ||
129 | '!src/scripts/main.js', | ||
130 | 'test/specs/**/*.js', | ||
131 | ], | ||
132 | options: jasmineOptions(false, null), | ||
133 | }, | ||
134 | }, | ||
135 | |||
136 | }); | ||
53 | }; | 137 | }; | ... | ... |
... | @@ -14,7 +14,9 @@ | ... | @@ -14,7 +14,9 @@ |
14 | "tests" | 14 | "tests" |
15 | ], | 15 | ], |
16 | "dependencies": { | 16 | "dependencies": { |
17 | "jquery": "", | ||
17 | "backbone": "~1.1.2", | 18 | "backbone": "~1.1.2", |
19 | "backbone-nested-models": "git@gitlab.brainfood.com:brainfood/backbone-nested-models.git", | ||
18 | "underscore": "~1", | 20 | "underscore": "~1", |
19 | "requirejs": "~2.1.17" | 21 | "requirejs": "~2.1.17" |
20 | } | 22 | } | ... | ... |
... | @@ -10,6 +10,10 @@ | ... | @@ -10,6 +10,10 @@ |
10 | "dependencies": { | 10 | "dependencies": { |
11 | }, | 11 | }, |
12 | "devDependencies": { | 12 | "devDependencies": { |
13 | "grunt-contrib-jasmine": "~0", | ||
14 | "jasmine-jquery": "^2.0.6", | ||
15 | "grunt-template-jasmine-istanbul": "~0", | ||
16 | "grunt-template-jasmine-requirejs": "~0", | ||
13 | "grunt": "~0", | 17 | "grunt": "~0", |
14 | "grunt-monty-python": "git+ssh://git@gitlab.brainfood.com:brainfood/grunt-monty-python.git" | 18 | "grunt-monty-python": "git+ssh://git@gitlab.brainfood.com:brainfood/grunt-monty-python.git" |
15 | }, | 19 | }, | ... | ... |
... | @@ -6,9 +6,21 @@ require = (function() { | ... | @@ -6,9 +6,21 @@ require = (function() { |
6 | var require = { | 6 | var require = { |
7 | baseUrl: 'scripts', | 7 | baseUrl: 'scripts', |
8 | deps: ['main'], | 8 | deps: ['main'], |
9 | shim: { | ||
10 | 'backbone': { | ||
11 | deps: ['underscore', 'jquery'], | ||
12 | exports: 'Backbone', | ||
13 | }, | ||
14 | 'backbone-validation': { | ||
15 | deps: ['backbone'], | ||
16 | }, | ||
17 | }, | ||
9 | paths: { | 18 | paths: { |
19 | 'jquery': '../lib/bower/jquery/dist/jquery', | ||
10 | 'backbone': '../lib/bower/backbone/backbone', | 20 | 'backbone': '../lib/bower/backbone/backbone', |
11 | 'underscore': '../lib/bower/underscore/underscore', | 21 | 'underscore': '../lib/bower/underscore/underscore', |
22 | 'backbone-nested-models': '../lib/bower/backbone-nested-models/src/scripts/backbone-nested-models', | ||
23 | 'backbone-validation': '../lib/bower/backbone-validation/src/backbone-validation', | ||
12 | }, | 24 | }, |
13 | }; | 25 | }; |
14 | return require; | 26 | return require; | ... | ... |
src/scripts/main.js
0 → 100644
... | @@ -24,11 +24,11 @@ define(function(require) { | ... | @@ -24,11 +24,11 @@ define(function(require) { |
24 | } | 24 | } |
25 | 25 | ||
26 | function mergeStaticProps(startPtr, endPtr, obj, fieldName) { | 26 | function mergeStaticProps(startPtr, endPtr, obj, fieldName) { |
27 | return mergeStaticFunc(startPtr, endPtr, obj, fieldName, _.identity); | 27 | return mergeStatic(startPtr, endPtr, obj, fieldName, _.identity); |
28 | } | 28 | } |
29 | 29 | ||
30 | function mergeStaticSets(startPtr, endPtr, obj, fieldName) { | 30 | function mergeStaticSets(startPtr, endPtr, obj, fieldName) { |
31 | return _.keys(mergeStaticFunc(startPtr, endPtr, obj, fieldName, function arrayToMap(array) { | 31 | return _.keys(mergeStatic(startPtr, endPtr, obj, fieldName, function arrayToMap(array) { |
32 | var result = {}; | 32 | var result = {}; |
33 | _.each(array, function(value) { | 33 | _.each(array, function(value) { |
34 | result[value] = true; | 34 | result[value] = true; | ... | ... |
-
Please register or sign in to post a comment