bpm 1.0.0.beta.4 → 1.0.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG.md +11 -0
  2. data/TODO.md +4 -10
  3. data/backbone/LICENSE +22 -0
  4. data/backbone/README +25 -0
  5. data/backbone/Rakefile +42 -0
  6. data/backbone/backbone-0.5.1.bpkg +0 -0
  7. data/backbone/examples/backbone-localstorage.js +84 -0
  8. data/backbone/examples/todos/destroy.png +0 -0
  9. data/backbone/examples/todos/index.html +87 -0
  10. data/backbone/examples/todos/todos.css +311 -0
  11. data/backbone/examples/todos/todos.js +258 -0
  12. data/backbone/index.html +2606 -0
  13. data/backbone/index.js +1 -0
  14. data/backbone/lib/backbone.js +1149 -0
  15. data/backbone/lib/index.js +1 -0
  16. data/backbone/package.json +14 -0
  17. data/backbone/test/collection.js +345 -0
  18. data/backbone/test/events.js +70 -0
  19. data/backbone/test/model.coffee +43 -0
  20. data/backbone/test/model.js +424 -0
  21. data/backbone/test/noconflict.js +12 -0
  22. data/backbone/test/router.js +116 -0
  23. data/backbone/test/speed.js +45 -0
  24. data/backbone/test/sync.js +133 -0
  25. data/backbone/test/test-zepto.html +30 -0
  26. data/backbone/test/test.html +31 -0
  27. data/backbone/test/vendor/jquery-1.5.js +8176 -0
  28. data/backbone/test/vendor/jslitmus.js +649 -0
  29. data/backbone/test/vendor/json2.js +481 -0
  30. data/backbone/test/vendor/qunit.css +196 -0
  31. data/backbone/test/vendor/qunit.js +1364 -0
  32. data/backbone/test/vendor/underscore-1.1.6.js +807 -0
  33. data/backbone/test/vendor/zepto-0.6.js +692 -0
  34. data/backbone/test/view.js +137 -0
  35. data/lib/bpm/cli/base.rb +22 -7
  36. data/lib/bpm/package.rb +17 -5
  37. data/lib/bpm/project.rb +49 -32
  38. data/lib/bpm/version.rb +1 -1
  39. data/spec/cli/add_spec.rb +22 -4
  40. data/spec/cli/fetch_spec.rb +0 -1
  41. data/spec/cli/init_spec.rb +25 -10
  42. data/spec/cli/list_spec.rb +103 -62
  43. data/spec/cli/pack_spec.rb +36 -4
  44. data/spec/fixtures/packages/backbone/LICENSE +22 -0
  45. data/spec/fixtures/packages/backbone/README +25 -0
  46. data/spec/fixtures/packages/backbone/Rakefile +42 -0
  47. data/spec/fixtures/packages/backbone/examples/backbone-localstorage.js +84 -0
  48. data/spec/fixtures/packages/backbone/examples/todos/destroy.png +0 -0
  49. data/spec/fixtures/packages/backbone/examples/todos/index.html +87 -0
  50. data/spec/fixtures/packages/backbone/examples/todos/todos.css +311 -0
  51. data/spec/fixtures/packages/backbone/examples/todos/todos.js +258 -0
  52. data/spec/fixtures/packages/backbone/index.html +2606 -0
  53. data/spec/fixtures/packages/backbone/lib/backbone.js +1149 -0
  54. data/spec/fixtures/packages/backbone/lib/index.js +1 -0
  55. data/spec/fixtures/packages/backbone/package.json +14 -0
  56. data/spec/fixtures/packages/backbone/test/collection.js +345 -0
  57. data/spec/fixtures/packages/backbone/test/events.js +70 -0
  58. data/spec/fixtures/packages/backbone/test/model.coffee +43 -0
  59. data/spec/fixtures/packages/backbone/test/model.js +424 -0
  60. data/spec/fixtures/packages/backbone/test/noconflict.js +12 -0
  61. data/spec/fixtures/packages/backbone/test/router.js +116 -0
  62. data/spec/fixtures/packages/backbone/test/speed.js +45 -0
  63. data/spec/fixtures/packages/backbone/test/sync.js +133 -0
  64. data/spec/fixtures/packages/backbone/test/test-zepto.html +30 -0
  65. data/spec/fixtures/packages/backbone/test/test.html +31 -0
  66. data/spec/fixtures/packages/backbone/test/vendor/jquery-1.5.js +8176 -0
  67. data/spec/fixtures/packages/backbone/test/vendor/jslitmus.js +649 -0
  68. data/spec/fixtures/packages/backbone/test/vendor/json2.js +481 -0
  69. data/spec/fixtures/packages/backbone/test/vendor/qunit.css +196 -0
  70. data/spec/fixtures/packages/backbone/test/vendor/qunit.js +1364 -0
  71. data/spec/fixtures/packages/backbone/test/vendor/underscore-1.1.6.js +807 -0
  72. data/spec/fixtures/packages/backbone/test/vendor/zepto-0.6.js +692 -0
  73. data/spec/fixtures/packages/backbone/test/view.js +137 -0
  74. data/spec/fixtures/projects/init_app/assets/bpm_libs.js +1 -1
  75. data/spec/fixtures/projects/init_app/assets/bpm_styles.css +1 -1
  76. data/spec/fixtures/projects/init_app/new_project.json +1 -10
  77. data/spec/pipeline_spec.rb +5 -5
  78. data/spec/plugins/minifier_spec.rb +1 -1
  79. data/spec/plugins/transport_spec.rb +1 -1
  80. metadata +116 -28
  81. data/spec/fixtures/projects/init_app/assets/new_project/bpm_libs.js +0 -6
  82. data/spec/fixtures/projects/init_app/assets/new_project/bpm_styles.css +0 -5
@@ -0,0 +1,424 @@
1
+ $(document).ready(function() {
2
+
3
+ module("Backbone.Model");
4
+
5
+ // Variable to catch the last request.
6
+ window.lastRequest = null;
7
+
8
+ window.originalSync = Backbone.sync;
9
+
10
+ // Stub out Backbone.request...
11
+ Backbone.sync = function() {
12
+ lastRequest = _.toArray(arguments);
13
+ };
14
+
15
+ var attrs = {
16
+ id : '1-the-tempest',
17
+ title : "The Tempest",
18
+ author : "Bill Shakespeare",
19
+ length : 123
20
+ };
21
+
22
+ var proxy = Backbone.Model.extend();
23
+ var doc = new proxy(attrs);
24
+
25
+ var klass = Backbone.Collection.extend({
26
+ url : function() { return '/collection'; }
27
+ });
28
+
29
+ var collection = new klass();
30
+ collection.add(doc);
31
+
32
+ test("Model: initialize", function() {
33
+ var Model = Backbone.Model.extend({
34
+ initialize: function() {
35
+ this.one = 1;
36
+ equals(this.collection, collection);
37
+ }
38
+ });
39
+ var model = new Model({}, {collection: collection});
40
+ equals(model.one, 1);
41
+ equals(model.collection, collection);
42
+ });
43
+
44
+ test("Model: initialize with attributes and options", function() {
45
+ var Model = Backbone.Model.extend({
46
+ initialize: function(attributes, options) {
47
+ this.one = options.one;
48
+ }
49
+ });
50
+ var model = new Model({}, {one: 1});
51
+ equals(model.one, 1);
52
+ });
53
+
54
+ test("Model: url", function() {
55
+ equals(doc.url(), '/collection/1-the-tempest');
56
+ doc.collection.url = '/collection/';
57
+ equals(doc.url(), '/collection/1-the-tempest');
58
+ doc.collection = null;
59
+ var failed = false;
60
+ try {
61
+ doc.url();
62
+ } catch (e) {
63
+ failed = true;
64
+ }
65
+ equals(failed, true);
66
+ doc.collection = collection;
67
+ });
68
+
69
+ test("Model: url when using urlRoot, and uri encoding", function() {
70
+ var Model = Backbone.Model.extend({
71
+ urlRoot: '/collection'
72
+ });
73
+ var model = new Model();
74
+ equals(model.url(), '/collection');
75
+ model.set({id: '+1+'});
76
+ equals(model.url(), '/collection/%2B1%2B');
77
+ });
78
+
79
+ test("Model: clone", function() {
80
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
81
+ a = new Backbone.Model(attrs);
82
+ b = a.clone();
83
+ equals(a.get('foo'), 1);
84
+ equals(a.get('bar'), 2);
85
+ equals(a.get('baz'), 3);
86
+ equals(b.get('foo'), a.get('foo'), "Foo should be the same on the clone.");
87
+ equals(b.get('bar'), a.get('bar'), "Bar should be the same on the clone.");
88
+ equals(b.get('baz'), a.get('baz'), "Baz should be the same on the clone.");
89
+ a.set({foo : 100});
90
+ equals(a.get('foo'), 100);
91
+ equals(b.get('foo'), 1, "Changing a parent attribute does not change the clone.");
92
+ });
93
+
94
+ test("Model: isNew", function() {
95
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
96
+ a = new Backbone.Model(attrs);
97
+ ok(a.isNew(), "it should be new");
98
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3, 'id': -5 };
99
+ a = new Backbone.Model(attrs);
100
+ ok(!a.isNew(), "any defined ID is legal, negative or positive");
101
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3, 'id': 0 };
102
+ a = new Backbone.Model(attrs);
103
+ ok(!a.isNew(), "any defined ID is legal, including zero");
104
+ ok( new Backbone.Model({ }).isNew(), "is true when there is no id");
105
+ ok(!new Backbone.Model({ 'id': 2 }).isNew(), "is false for a positive integer");
106
+ ok(!new Backbone.Model({ 'id': -5 }).isNew(), "is false for a negative integer");
107
+ });
108
+
109
+ test("Model: get", function() {
110
+ equals(doc.get('title'), 'The Tempest');
111
+ equals(doc.get('author'), 'Bill Shakespeare');
112
+ });
113
+
114
+ test("Model: escape", function() {
115
+ equals(doc.escape('title'), 'The Tempest');
116
+ doc.set({audience: 'Bill & Bob'});
117
+ equals(doc.escape('audience'), 'Bill & Bob');
118
+ doc.set({audience: 'Tim > Joan'});
119
+ equals(doc.escape('audience'), 'Tim > Joan');
120
+ doc.set({audience: 10101});
121
+ equals(doc.escape('audience'), '10101');
122
+ doc.unset('audience');
123
+ equals(doc.escape('audience'), '');
124
+ });
125
+
126
+ test("Model: has", function() {
127
+ attrs = {};
128
+ a = new Backbone.Model(attrs);
129
+ equals(a.has("name"), false);
130
+ _([true, "Truth!", 1, false, '', 0]).each(function(value) {
131
+ a.set({'name': value});
132
+ equals(a.has("name"), true);
133
+ });
134
+ a.unset('name');
135
+ equals(a.has('name'), false);
136
+ _([null, undefined]).each(function(value) {
137
+ a.set({'name': value});
138
+ equals(a.has("name"), false);
139
+ });
140
+ });
141
+
142
+ test("Model: set and unset", function() {
143
+ attrs = {id: 'id', foo: 1, bar: 2, baz: 3};
144
+ a = new Backbone.Model(attrs);
145
+ var changeCount = 0;
146
+ a.bind("change:foo", function() { changeCount += 1; });
147
+ a.set({'foo': 2});
148
+ ok(a.get('foo')== 2, "Foo should have changed.");
149
+ ok(changeCount == 1, "Change count should have incremented.");
150
+ a.set({'foo': 2}); // set with value that is not new shouldn't fire change event
151
+ ok(a.get('foo')== 2, "Foo should NOT have changed, still 2");
152
+ ok(changeCount == 1, "Change count should NOT have incremented.");
153
+
154
+ a.unset('foo');
155
+ ok(a.get('foo')== null, "Foo should have changed");
156
+ ok(changeCount == 2, "Change count should have incremented for unset.");
157
+
158
+ a.unset('id');
159
+ equals(a.id, undefined, "Unsetting the id should remove the id property.");
160
+ });
161
+
162
+ test("Model: multiple unsets", function() {
163
+ var i = 0;
164
+ var counter = function(){ i++; };
165
+ var model = new Backbone.Model({a: 1});
166
+ model.bind("change:a", counter);
167
+ model.set({a: 2});
168
+ model.unset('a');
169
+ model.unset('a');
170
+ equals(i, 2, 'Unset does not fire an event for missing attributes.');
171
+ });
172
+
173
+ test("Model: using a non-default id attribute.", function() {
174
+ var MongoModel = Backbone.Model.extend({idAttribute : '_id'});
175
+ var model = new MongoModel({id: 'eye-dee', _id: 25, title: 'Model'});
176
+ equals(model.get('id'), 'eye-dee');
177
+ equals(model.id, 25);
178
+ model.unset('_id');
179
+ equals(model.id, undefined);
180
+ });
181
+
182
+ test("Model: set an empty string", function() {
183
+ var model = new Backbone.Model({name : "Model"});
184
+ model.set({name : ''});
185
+ equals(model.get('name'), '');
186
+ });
187
+
188
+ test("Model: clear", function() {
189
+ var changed;
190
+ var model = new Backbone.Model({name : "Model"});
191
+ model.bind("change:name", function(){ changed = true; });
192
+ model.clear();
193
+ equals(changed, true);
194
+ equals(model.get('name'), undefined);
195
+ });
196
+
197
+ test("Model: defaults", function() {
198
+ var Defaulted = Backbone.Model.extend({
199
+ defaults: {
200
+ "one": 1,
201
+ "two": 2
202
+ }
203
+ });
204
+ var model = new Defaulted({two: null});
205
+ equals(model.get('one'), 1);
206
+ equals(model.get('two'), null);
207
+ Defaulted = Backbone.Model.extend({
208
+ defaults: function() {
209
+ return {
210
+ "one": 3,
211
+ "two": 4
212
+ };
213
+ }
214
+ });
215
+ var model = new Defaulted({two: null});
216
+ equals(model.get('one'), 3);
217
+ equals(model.get('two'), null);
218
+ });
219
+
220
+ test("Model: change, hasChanged, changedAttributes, previous, previousAttributes", function() {
221
+ var model = new Backbone.Model({name : "Tim", age : 10});
222
+ equals(model.changedAttributes(), false);
223
+ model.bind('change', function() {
224
+ ok(model.hasChanged('name'), 'name changed');
225
+ ok(!model.hasChanged('age'), 'age did not');
226
+ ok(_.isEqual(model.changedAttributes(), {name : 'Rob'}), 'changedAttributes returns the changed attrs');
227
+ equals(model.previous('name'), 'Tim');
228
+ ok(_.isEqual(model.previousAttributes(), {name : "Tim", age : 10}), 'previousAttributes is correct');
229
+ });
230
+ model.set({name : 'Rob'}, {silent : true});
231
+ equals(model.hasChanged(), true);
232
+ equals(model.hasChanged('name'), true);
233
+ model.change();
234
+ equals(model.get('name'), 'Rob');
235
+ });
236
+
237
+ test("Model: change with options", function() {
238
+ var value;
239
+ var model = new Backbone.Model({name: 'Rob'});
240
+ model.bind('change', function(model, options) {
241
+ value = options.prefix + model.get('name');
242
+ });
243
+ model.set({name: 'Bob'}, {silent: true});
244
+ model.change({prefix: 'Mr. '});
245
+ equals(value, 'Mr. Bob');
246
+ model.set({name: 'Sue'}, {prefix: 'Ms. '});
247
+ equals(value, 'Ms. Sue');
248
+ });
249
+
250
+ test("Model: change after initialize", function () {
251
+ var changed = 0;
252
+ var attrs = {id: 1, label: 'c'};
253
+ var obj = new Backbone.Model(attrs);
254
+ obj.bind('change', function() { changed += 1; });
255
+ obj.set(attrs);
256
+ equals(changed, 0);
257
+ });
258
+
259
+ test("Model: save within change event", function () {
260
+ var model = new Backbone.Model({firstName : "Taylor", lastName: "Swift"});
261
+ model.bind('change', function () {
262
+ model.save();
263
+ ok(_.isEqual(lastRequest[1], model));
264
+ });
265
+ model.set({lastName: 'Hicks'});
266
+ });
267
+
268
+ test("Model: save", function() {
269
+ doc.save({title : "Henry V"});
270
+ equals(lastRequest[0], 'update');
271
+ ok(_.isEqual(lastRequest[1], doc));
272
+ });
273
+
274
+ test("Model: fetch", function() {
275
+ doc.fetch();
276
+ ok(lastRequest[0], 'read');
277
+ ok(_.isEqual(lastRequest[1], doc));
278
+ });
279
+
280
+ test("Model: destroy", function() {
281
+ doc.destroy();
282
+ equals(lastRequest[0], 'delete');
283
+ ok(_.isEqual(lastRequest[1], doc));
284
+ });
285
+
286
+ test("Model: non-persisted destroy", function() {
287
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
288
+ a = new Backbone.Model(attrs);
289
+ a.sync = function() { throw "should not be called"; };
290
+ ok(a.destroy(), "non-persisted model should not call sync");
291
+ });
292
+
293
+ test("Model: validate", function() {
294
+ var lastError;
295
+ var model = new Backbone.Model();
296
+ model.validate = function(attrs) {
297
+ if (attrs.admin) return "Can't change admin status.";
298
+ };
299
+ model.bind('error', function(model, error) {
300
+ lastError = error;
301
+ });
302
+ var result = model.set({a: 100});
303
+ equals(result, model);
304
+ equals(model.get('a'), 100);
305
+ equals(lastError, undefined);
306
+ result = model.set({admin: true}, {silent: true});
307
+ equals(lastError, undefined);
308
+ equals(model.get('admin'), true);
309
+ result = model.set({a: 200, admin: true});
310
+ equals(result, false);
311
+ equals(model.get('a'), 100);
312
+ equals(lastError, "Can't change admin status.");
313
+ });
314
+
315
+ test("Model: validate on unset and clear", function() {
316
+ var error;
317
+ var model = new Backbone.Model({name: "One"});
318
+ model.validate = function(attrs) {
319
+ if ("name" in attrs) {
320
+ if (!attrs.name) {
321
+ error = true;
322
+ return "No thanks.";
323
+ }
324
+ }
325
+ };
326
+ model.set({name: "Two"});
327
+ equals(model.get('name'), 'Two');
328
+ equals(error, undefined);
329
+ model.unset('name');
330
+ equals(error, true);
331
+ equals(model.get('name'), 'Two');
332
+ model.clear();
333
+ equals(model.get('name'), 'Two');
334
+ delete model.validate;
335
+ model.clear();
336
+ equals(model.get('name'), undefined);
337
+ });
338
+
339
+ test("Model: validate with error callback", function() {
340
+ var lastError, boundError;
341
+ var model = new Backbone.Model();
342
+ model.validate = function(attrs) {
343
+ if (attrs.admin) return "Can't change admin status.";
344
+ };
345
+ var callback = function(model, error) {
346
+ lastError = error;
347
+ };
348
+ model.bind('error', function(model, error) {
349
+ boundError = true;
350
+ });
351
+ var result = model.set({a: 100}, {error: callback});
352
+ equals(result, model);
353
+ equals(model.get('a'), 100);
354
+ equals(lastError, undefined);
355
+ equals(boundError, undefined);
356
+ result = model.set({a: 200, admin: true}, {error: callback});
357
+ equals(result, false);
358
+ equals(model.get('a'), 100);
359
+ equals(lastError, "Can't change admin status.");
360
+ equals(boundError, undefined);
361
+ });
362
+
363
+ test("Model: defaults always extend attrs (#459)", function() {
364
+ var Defaulted = Backbone.Model.extend({
365
+ defaults: {one: 1},
366
+ initialize : function(attrs, opts) {
367
+ equals(attrs.one, 1);
368
+ }
369
+ });
370
+ var providedattrs = new Defaulted({});
371
+ var emptyattrs = new Defaulted();
372
+ });
373
+
374
+ test("Model: Inherit class properties", function() {
375
+ var Parent = Backbone.Model.extend({
376
+ instancePropSame: function() {},
377
+ instancePropDiff: function() {}
378
+ }, {
379
+ classProp: function() {}
380
+ });
381
+ var Child = Parent.extend({
382
+ instancePropDiff: function() {}
383
+ });
384
+
385
+ var adult = new Parent;
386
+ var kid = new Child;
387
+
388
+ equals(Child.classProp, Parent.classProp);
389
+ notEqual(Child.classProp, undefined);
390
+
391
+ equals(kid.instancePropSame, adult.instancePropSame);
392
+ notEqual(kid.instancePropSame, undefined);
393
+
394
+ notEqual(Child.prototype.instancePropDiff, Parent.prototype.instancePropDiff);
395
+ notEqual(Child.prototype.instancePropDiff, undefined);
396
+ });
397
+
398
+ test("Model: Nested change events don't clobber previous attributes", function() {
399
+ var A = Backbone.Model.extend({
400
+ initialize: function() {
401
+ this.bind("change:state", function(a, newState) {
402
+ equals(a.previous('state'), undefined);
403
+ equals(newState, 'hello');
404
+ // Fire a nested change event.
405
+ this.set({ other: "whatever" });
406
+ });
407
+ }
408
+ });
409
+
410
+ var B = Backbone.Model.extend({
411
+ initialize: function() {
412
+ this.get("a").bind("change:state", function(a, newState) {
413
+ equals(a.previous('state'), undefined);
414
+ equals(newState, 'hello');
415
+ });
416
+ }
417
+ });
418
+
419
+ a = new A();
420
+ b = new B({a: a});
421
+ a.set({state: 'hello'});
422
+ });
423
+
424
+ });
@@ -0,0 +1,12 @@
1
+ $(document).ready(function() {
2
+
3
+ module("Backbone.noConflict");
4
+
5
+ test('Backbone.noConflict', function() {
6
+ var noconflictBackbone = Backbone.noConflict();
7
+ equals(window.Backbone, undefined, 'Returned window.Backbone');
8
+ window.Backbone = noconflictBackbone;
9
+ equals(window.Backbone, noconflictBackbone, 'Backbone is still pointing to the original Backbone');
10
+ });
11
+
12
+ });
@@ -0,0 +1,116 @@
1
+ $(document).ready(function() {
2
+
3
+ module("Backbone.Router");
4
+
5
+ var Router = Backbone.Router.extend({
6
+
7
+ routes: {
8
+ "search/:query": "search",
9
+ "search/:query/p:page": "search",
10
+ "splat/*args/end": "splat",
11
+ "*first/complex-:part/*rest": "complex",
12
+ ":entity?*args": "query",
13
+ "*anything": "anything"
14
+ },
15
+
16
+ initialize : function(options) {
17
+ this.testing = options.testing;
18
+ },
19
+
20
+ search : function(query, page) {
21
+ this.query = query;
22
+ this.page = page;
23
+ },
24
+
25
+ splat : function(args) {
26
+ this.args = args;
27
+ },
28
+
29
+ complex : function(first, part, rest) {
30
+ this.first = first;
31
+ this.part = part;
32
+ this.rest = rest;
33
+ },
34
+
35
+ query : function(entity, args) {
36
+ this.entity = entity;
37
+ this.queryArgs = args;
38
+ },
39
+
40
+ anything : function(whatever) {
41
+ this.anything = whatever;
42
+ }
43
+
44
+ });
45
+
46
+ Backbone.history = null;
47
+ var router = new Router({testing: 101});
48
+
49
+ Backbone.history.interval = 9;
50
+ Backbone.history.start({pushState: false});
51
+
52
+ test("Router: initialize", function() {
53
+ equals(router.testing, 101);
54
+ });
55
+
56
+ asyncTest("Router: routes (simple)", 2, function() {
57
+ window.location.hash = 'search/news';
58
+ setTimeout(function() {
59
+ equals(router.query, 'news');
60
+ equals(router.page, undefined);
61
+ start();
62
+ }, 10);
63
+ });
64
+
65
+ asyncTest("Router: routes (two part)", 2, function() {
66
+ window.location.hash = 'search/nyc/p10';
67
+ setTimeout(function() {
68
+ equals(router.query, 'nyc');
69
+ equals(router.page, '10');
70
+ start();
71
+ }, 10);
72
+ });
73
+
74
+ test("Router: routes via navigate", 2, function() {
75
+ Backbone.history.navigate('search/manhattan/p20', true);
76
+ equals(router.query, 'manhattan');
77
+ equals(router.page, '20');
78
+ });
79
+
80
+ asyncTest("Router: routes (splats)", function() {
81
+ window.location.hash = 'splat/long-list/of/splatted_99args/end';
82
+ setTimeout(function() {
83
+ equals(router.args, 'long-list/of/splatted_99args');
84
+ start();
85
+ }, 10);
86
+ });
87
+
88
+ asyncTest("Router: routes (complex)", 3, function() {
89
+ window.location.hash = 'one/two/three/complex-part/four/five/six/seven';
90
+ setTimeout(function() {
91
+ equals(router.first, 'one/two/three');
92
+ equals(router.part, 'part');
93
+ equals(router.rest, 'four/five/six/seven');
94
+ start();
95
+ }, 10);
96
+ });
97
+
98
+ asyncTest("Router: routes (query)", 2, function() {
99
+ window.location.hash = 'mandel?a=b&c=d';
100
+ setTimeout(function() {
101
+ equals(router.entity, 'mandel');
102
+ equals(router.queryArgs, 'a=b&c=d');
103
+ start();
104
+ }, 10);
105
+ });
106
+
107
+ asyncTest("Router: routes (anything)", 1, function() {
108
+ window.location.hash = 'doesnt-match-a-route';
109
+ setTimeout(function() {
110
+ equals(router.anything, 'doesnt-match-a-route');
111
+ start();
112
+ window.location.hash = '';
113
+ }, 10);
114
+ });
115
+
116
+ });
@@ -0,0 +1,45 @@
1
+ (function(){
2
+
3
+ var object = {};
4
+ _.extend(object, Backbone.Events);
5
+ var fn = function(){};
6
+
7
+ JSLitmus.test('Events: bind + unbind', function() {
8
+ object.bind("event", fn);
9
+ object.unbind("event", fn);
10
+ });
11
+
12
+ object.bind('test:trigger', fn);
13
+
14
+ JSLitmus.test('Events: trigger', function() {
15
+ object.trigger('test:trigger');
16
+ });
17
+
18
+ object.bind('test:trigger2', fn);
19
+ object.bind('test:trigger2', fn);
20
+
21
+ JSLitmus.test('Events: trigger 2, passing 5 args', function() {
22
+ object.trigger('test:trigger2', 1, 2, 3, 4, 5);
23
+ });
24
+
25
+ var model = new Backbone.Model;
26
+
27
+ JSLitmus.test('Model: set Math.random()', function() {
28
+ model.set({number: Math.random()});
29
+ });
30
+
31
+ var eventModel = new Backbone.Model;
32
+ eventModel.bind('change', fn);
33
+
34
+ JSLitmus.test('Model: set rand() with an event', function() {
35
+ eventModel.set({number: Math.random()});
36
+ });
37
+
38
+ var keyModel = new Backbone.Model;
39
+ keyModel.bind('change:number', fn);
40
+
41
+ JSLitmus.test('Model: set rand() with an attribute observer', function() {
42
+ keyModel.set({number: Math.random()});
43
+ });
44
+
45
+ })();