honkster-jelly 0.13.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Jelly. a sweet unobtrusive javascript framework for Rails
3
3
  *
4
- * version 0.13.0
4
+ * version 0.13.1
5
5
  *
6
6
  * Copyright (c) 2009 Pivotal Labs
7
7
  * Licensed under the MIT license.
@@ -62,7 +62,7 @@
62
62
  throw "op " + JSON.stringify(op) + " is not an attach op"
63
63
  }
64
64
  var args = [op[1]];
65
- args.concat.apply(args, op.slice(2));
65
+ args.push.apply(args, op.slice(2));
66
66
  Jelly.Observers.attach.apply(this, args);
67
67
  },
68
68
 
@@ -1,28 +1,28 @@
1
- describe("Jelly", function() {
1
+ describe("Jelly", function () {
2
2
  var our_token;
3
3
 
4
- beforeEach(function() {
4
+ beforeEach(function () {
5
5
  spyOn($, 'ajax');
6
6
  our_token = "authenticity token";
7
7
  window._token = our_token;
8
8
  Jelly.init();
9
9
  });
10
10
 
11
- describe(".add", function() {
12
- afterEach(function() {
11
+ describe(".add", function () {
12
+ afterEach(function () {
13
13
  delete Jelly.Pages.all["test-name"];
14
14
  });
15
15
 
16
- it("instantiates a Page with the passed-in name and attaches the set of passed-in functions to the Page object", function() {
16
+ it("instantiates a Page with the passed-in name and attaches the set of passed-in functions to the Page object", function () {
17
17
  expect(Jelly.Pages.all["test-name"]).toEqual(undefined);
18
18
 
19
- var showFn = function() {
19
+ var showFn = function () {
20
20
  };
21
- var newFn = function() {
21
+ var newFn = function () {
22
22
  };
23
- var indexFn = function() {
23
+ var indexFn = function () {
24
24
  };
25
- var newPage = Jelly.Pages.add("test-name", {show: showFn}, {'new': newFn}, {index: indexFn});
25
+ var newPage = Jelly.Pages.add("test-name", {show:showFn}, {'new':newFn}, {index:indexFn});
26
26
  expect(Jelly.Pages.all["test-name"]).toNotEqual(undefined);
27
27
  expect(newPage).toEqual(Jelly.Pages.all["test-name"]);
28
28
  expect(newPage.show).toEqual(showFn);
@@ -30,57 +30,333 @@ describe("Jelly", function() {
30
30
  expect(newPage.index).toEqual(indexFn);
31
31
  });
32
32
  });
33
-
34
- describe(".run", function() {
35
- describe("attach", function() {
36
- describe("when the component does not respond to init", function() {
37
- describe("when the component is referenced as a String", function() {
38
- beforeEach(function() {
33
+
34
+ describe(".run", function () {
35
+ describe("attach", function () {
36
+ describe("when the component does not respond to init", function () {
37
+ describe("when the component is referenced as a String", function () {
38
+ beforeEach(function () {
39
39
  window.MyComponent = {
40
40
  };
41
41
  });
42
-
43
- afterEach(function() {
42
+
43
+ afterEach(function () {
44
44
  delete window.MyComponent;
45
45
  });
46
-
47
- it("attaches the component to Jelly.observers", function() {
46
+
47
+ it("attaches the component to Jelly.observers", function () {
48
48
  Jelly.run(["attach", "MyComponent"]);
49
49
  expect(Jelly.observers).toContain(MyComponent);
50
50
  });
51
51
  });
52
-
53
- describe("when the component is referenced as itself", function() {
54
- it("attaches the component to Jelly.observers", function() {
52
+
53
+ describe("when the component is referenced as itself", function () {
54
+ it("attaches the component to Jelly.observers", function () {
55
55
  var component = {};
56
56
  Jelly.run(["attach", component]);
57
57
  expect(Jelly.observers).toContain(component);
58
58
  });
59
59
  });
60
60
  })
61
+
62
+ describe("when component responds to init", function () {
63
+ describe("when the component's init method returns undefined", function () {
64
+ describe("when the component is referenced as a String", function () {
65
+ beforeEach(function () {
66
+ window.MyComponent = {
67
+ init:function () {
68
+ }
69
+ };
70
+ });
71
+
72
+ afterEach(function () {
73
+ delete window.MyComponent;
74
+ });
75
+
76
+ it("calls the init method on the component and attaches the component to Jelly.observers", function () {
77
+ spyOn(MyComponent, 'init');
78
+ Jelly.run(["attach", MyComponent, 1, 2]);
79
+ expect(MyComponent.init).wasCalledWith(1, 2);
80
+ expect(Jelly.observers).toContain(MyComponent);
81
+ });
82
+ });
83
+
84
+ describe("when the component is referenced as itself", function () {
85
+ var component;
86
+ beforeEach(function () {
87
+ component = {
88
+ init:function () {
89
+ }
90
+ };
91
+ });
92
+
93
+ it("calls the init method on the component and attaches the component to Jelly.observers", function () {
94
+ spyOn(component, 'init');
95
+ Jelly.run(["attach", component, 1, 2]);
96
+ expect(component.init).wasCalledWith(1, 2);
97
+ expect(Jelly.observers).toContain(component);
98
+ });
99
+ });
100
+ });
101
+
102
+ describe("when the component's init method returns false", function () {
103
+ var component;
104
+ beforeEach(function () {
105
+ component = {
106
+ init:function () {
107
+ component.initCalled = true;
108
+ return false;
109
+ }
110
+ };
111
+ });
112
+
113
+ it("calls the init method on the component and does not attaches an observer to Jelly.observers", function () {
114
+ var originalObserversLength = Jelly.observers.length;
115
+ Jelly.run(["attach", component, 1, 2]);
116
+ expect(component.initCalled).toBeTruthy();
117
+ expect(Jelly.observers.length).toEqual(originalObserversLength);
118
+ expect(Jelly.observers).toNotContain(component);
119
+ });
120
+ });
121
+
122
+ describe("when the component's init method returns null", function () {
123
+ var component;
124
+ beforeEach(function () {
125
+ component = {
126
+ init:function () {
127
+ component.initCalled = true;
128
+ return null;
129
+ }
130
+ };
131
+ });
132
+
133
+ it("calls the init method on the component and does not attaches an observer to Jelly.observers", function () {
134
+ var originalObserversLength = Jelly.observers.length;
135
+ Jelly.run(["attach", component, 1, 2]);
136
+ expect(component.initCalled).toBeTruthy();
137
+ expect(Jelly.observers.length).toEqual(originalObserversLength);
138
+ expect(Jelly.observers).toNotContain(component);
139
+ });
140
+ });
141
+
142
+ describe("when the component's init method returns an object", function () {
143
+ it("attaches the returned object (instead of the component) to Jelly.observers", function () {
144
+ var observer = new Object();
145
+ var component = {
146
+ init:function () {
147
+ return observer;
148
+ }
149
+ };
150
+ Jelly.run(["attach", component, 1, 2]);
151
+ expect(Jelly.observers).toContain(observer);
152
+ expect(Jelly.observers).toNotContain(component);
153
+ });
154
+ });
155
+ });
156
+ });
157
+
158
+ describe("notify", function () {
159
+ beforeEach(function () {
160
+ Jelly.Pages.add("MyPage", {
161
+ on_my_method:function () {
162
+ }
163
+ });
164
+ Jelly.run(["attach", "Jelly.Page", "MyPage", "index"]);
165
+ });
166
+
167
+ describe("when bound to the default Jelly.observers collection", function () {
168
+ describe("the active page object", function () {
169
+ describe("when the notify method is defined on the page", function () {
170
+ it("should call the notify method on the page", function () {
171
+ spyOn(page, 'on_my_method');
172
+ Jelly.run(["notify", "on_my_method", "arg1", "arg2"]);
173
+ expect(page.on_my_method).wasCalled();
174
+ expect(page.on_my_method).wasCalledWith('arg1', 'arg2');
175
+ });
176
+
177
+ describe("when there are attached components", function () {
178
+ it("calls the notify methods in the order of the attached components", function () {
179
+ var component = {
180
+ on_my_method:function () {
181
+ }
182
+ };
183
+ Jelly.attach(component);
184
+
185
+ var functionsCalledInOrder = [];
186
+ spyOn(page, 'on_my_method').andCallFake(function () {
187
+ functionsCalledInOrder.push("page");
188
+ });
189
+ spyOn(component, 'on_my_method').andCallFake(function () {
190
+ functionsCalledInOrder.push("component");
191
+ });
192
+ Jelly.run(["notify", "on_my_method", "arg1", "arg2"]);
193
+ expect(page.on_my_method).wasCalled();
194
+ expect(page.on_my_method).wasCalledWith('arg1', 'arg2');
195
+ expect(component.on_my_method).wasCalled();
196
+ expect(component.on_my_method).wasCalledWith('arg1', 'arg2');
197
+ expect(functionsCalledInOrder).toEqual(["page", "component"]);
198
+ });
199
+ });
200
+ });
201
+
202
+ describe("when the page object does not define the notify method", function () {
203
+ it("does not blow up", function () {
204
+ expect(page.on_my_undefined_method).toBe(undefined);
205
+ Jelly.run(["notify", "on_my_undefined_method", "arg1", "arg2"]);
206
+ });
207
+ });
208
+ });
209
+
210
+ describe("when the 'on' parameter is present", function () {
211
+ beforeEach(function () {
212
+ GlobalObject = {on_my_method:function () {
213
+ }};
214
+ GlobalObject.secondObject = {on_my_method:function () {
215
+ }};
216
+ });
217
+
218
+ afterEach(function () {
219
+ delete GlobalObject;
220
+ });
221
+ });
222
+ });
223
+
224
+ describe("when bound to an array of custom observers", function () {
225
+ it("notifies the given observers and not the existing Jelly.observers, unless in the list of observers", function () {
226
+ var component = {
227
+ on_my_method:function () {
228
+ }
229
+ };
230
+ Jelly.attach("Jelly.Page", "MyPage", "index");
231
+ Jelly.attach(component);
232
+
233
+ spyOn(page, 'on_my_method');
234
+ spyOn(component, 'on_my_method');
235
+
236
+ var customObserver1 = {on_my_method:function () {
237
+ }};
238
+ spyOn(customObserver1, 'on_my_method');
239
+ var customObserver2 = {on_my_method:function () {
240
+ }};
241
+ spyOn(customObserver2, 'on_my_method');
242
+
243
+ Jelly.run.call([customObserver1, customObserver2], ["notify", "on_my_method", "arg1", "arg2"]);
244
+
245
+ expect(page.on_my_method).wasNotCalled();
246
+ expect(component.on_my_method).wasNotCalled();
247
+
248
+ expect(customObserver1.on_my_method).wasCalled();
249
+ expect(customObserver1.on_my_method).wasCalledWith('arg1', 'arg2');
250
+ expect(customObserver2.on_my_method).wasCalled();
251
+ expect(customObserver2.on_my_method).wasCalledWith('arg1', 'arg2');
252
+ });
253
+ });
254
+
255
+ describe("an observer listening to on_notify", function () {
256
+ it("receives a notify instruction", function () {
257
+ var observer = {
258
+ on_notify:function () {
259
+ }
260
+ };
261
+ spyOn(observer, 'on_notify');
262
+
263
+ Jelly.run.call([observer], ["notify", "on_my_method", "arg1", "arg2"]);
264
+
265
+ expect(observer.on_notify).wasCalledWith("on_my_method", "arg1", "arg2");
266
+ });
267
+ });
268
+
269
+ describe("an observer listening to the notify method", function () {
270
+ var observer;
271
+ beforeEach(function () {
272
+ observer = {
273
+ on_my_method:function () {
274
+ }
275
+ };
276
+ Jelly.attach(observer);
277
+ expect(Jelly.observers).toContain(observer);
278
+ });
279
+
280
+ describe("when the observer does not have a detach method defined", function () {
281
+ beforeEach(function () {
282
+ expect(observer.detach).toBe(undefined);
283
+ });
284
+
285
+ it("leaves the observer in Jelly.observers and calls the notify method on the observer", function () {
286
+ spyOn(observer, "on_my_method");
287
+
288
+ Jelly.run(["notify", "on_my_method"]);
289
+ expect(Jelly.observers).toContain(observer);
290
+ expect(observer.on_my_method).wasCalled();
291
+ });
292
+ });
293
+
294
+ describe("when the observer a detach method defined", function () {
295
+ describe("when the detach method is truthy", function () {
296
+ var anotherObserver;
297
+ beforeEach(function () {
298
+ observer.detach = function () {
299
+ return true;
300
+ };
301
+ anotherObserver = {
302
+ on_my_method:function () {
303
+ }
304
+ };
305
+ Jelly.attach(anotherObserver);
306
+ });
307
+
308
+ it("removes observer in Jelly.observers, does not call the notify method on the observer, and calls the other observers", function () {
309
+ spyOn(observer, "on_my_method");
310
+ spyOn(anotherObserver, "on_my_method");
311
+
312
+ Jelly.run(["notify", "on_my_method"]);
313
+ expect(Jelly.observers).toNotContain(observer);
314
+ expect(observer.on_my_method).wasNotCalled();
315
+ expect(anotherObserver.on_my_method).wasCalled();
316
+ });
317
+ });
318
+
319
+ describe("when the detach method is falsy", function () {
320
+ beforeEach(function () {
321
+ observer.detach = function () {
322
+ return undefined;
323
+ }
324
+ });
325
+
326
+ it("leaves the observer in Jelly.observers and calls the notify method on the observer", function () {
327
+ spyOn(observer, "on_my_method");
328
+
329
+ Jelly.run(["notify", "on_my_method"]);
330
+ expect(Jelly.observers).toContain(observer);
331
+ expect(observer.on_my_method).wasCalled();
332
+ });
333
+ });
334
+ });
335
+ });
336
+
61
337
  });
62
338
  });
63
339
 
64
- describe(".attach", function() {
65
- describe("when the component does not respond to init", function() {
66
- describe("when the component is referenced as a String", function() {
67
- beforeEach(function() {
340
+ describe(".attach", function () {
341
+ describe("when the component does not respond to init", function () {
342
+ describe("when the component is referenced as a String", function () {
343
+ beforeEach(function () {
68
344
  window.MyComponent = {
69
345
  };
70
346
  });
71
347
 
72
- afterEach(function() {
348
+ afterEach(function () {
73
349
  delete window.MyComponent;
74
350
  });
75
351
 
76
- it("attaches the component to Jelly.observers", function() {
352
+ it("attaches the component to Jelly.observers", function () {
77
353
  Jelly.attach("MyComponent");
78
354
  expect(Jelly.observers).toContain(MyComponent);
79
355
  });
80
356
  });
81
357
 
82
- describe("when the component is referenced as itself", function() {
83
- it("attaches the component to Jelly.observers", function() {
358
+ describe("when the component is referenced as itself", function () {
359
+ it("attaches the component to Jelly.observers", function () {
84
360
  var component = {};
85
361
  Jelly.attach(component);
86
362
  expect(Jelly.observers).toContain(component);
@@ -88,21 +364,21 @@ describe("Jelly", function() {
88
364
  });
89
365
  });
90
366
 
91
- describe("when component responds to init", function() {
92
- describe("when the component's init method returns undefined", function() {
93
- describe("when the component is referenced as a String", function() {
94
- beforeEach(function() {
367
+ describe("when component responds to init", function () {
368
+ describe("when the component's init method returns undefined", function () {
369
+ describe("when the component is referenced as a String", function () {
370
+ beforeEach(function () {
95
371
  window.MyComponent = {
96
- init: function() {
372
+ init:function () {
97
373
  }
98
374
  };
99
375
  });
100
376
 
101
- afterEach(function() {
377
+ afterEach(function () {
102
378
  delete window.MyComponent;
103
379
  });
104
380
 
105
- it("calls the init method on the component and attaches the component to Jelly.observers", function() {
381
+ it("calls the init method on the component and attaches the component to Jelly.observers", function () {
106
382
  spyOn(MyComponent, 'init');
107
383
  Jelly.attach(MyComponent, 1, 2);
108
384
  expect(MyComponent.init).wasCalledWith(1, 2);
@@ -110,16 +386,16 @@ describe("Jelly", function() {
110
386
  });
111
387
  });
112
388
 
113
- describe("when the component is referenced as itself", function() {
389
+ describe("when the component is referenced as itself", function () {
114
390
  var component;
115
- beforeEach(function() {
391
+ beforeEach(function () {
116
392
  component = {
117
- init: function() {
393
+ init:function () {
118
394
  }
119
395
  };
120
396
  });
121
397
 
122
- it("calls the init method on the component and attaches the component to Jelly.observers", function() {
398
+ it("calls the init method on the component and attaches the component to Jelly.observers", function () {
123
399
  spyOn(component, 'init');
124
400
  Jelly.attach(component, 1, 2);
125
401
  expect(component.init).wasCalledWith(1, 2);
@@ -128,18 +404,18 @@ describe("Jelly", function() {
128
404
  });
129
405
  });
130
406
 
131
- describe("when the component's init method returns false", function() {
407
+ describe("when the component's init method returns false", function () {
132
408
  var component;
133
- beforeEach(function() {
409
+ beforeEach(function () {
134
410
  component = {
135
- init: function() {
411
+ init:function () {
136
412
  component.initCalled = true;
137
413
  return false;
138
414
  }
139
415
  };
140
416
  });
141
417
 
142
- it("calls the init method on the component and does not attaches an observer to Jelly.observers", function() {
418
+ it("calls the init method on the component and does not attaches an observer to Jelly.observers", function () {
143
419
  var originalObserversLength = Jelly.observers.length;
144
420
  Jelly.attach(component, 1, 2);
145
421
  expect(component.initCalled).toBeTruthy();
@@ -148,18 +424,18 @@ describe("Jelly", function() {
148
424
  });
149
425
  });
150
426
 
151
- describe("when the component's init method returns null", function() {
427
+ describe("when the component's init method returns null", function () {
152
428
  var component;
153
- beforeEach(function() {
429
+ beforeEach(function () {
154
430
  component = {
155
- init: function() {
431
+ init:function () {
156
432
  component.initCalled = true;
157
433
  return null;
158
434
  }
159
435
  };
160
436
  });
161
437
 
162
- it("calls the init method on the component and does not attaches an observer to Jelly.observers", function() {
438
+ it("calls the init method on the component and does not attaches an observer to Jelly.observers", function () {
163
439
  var originalObserversLength = Jelly.observers.length;
164
440
  Jelly.attach(component, 1, 2);
165
441
  expect(component.initCalled).toBeTruthy();
@@ -168,11 +444,11 @@ describe("Jelly", function() {
168
444
  });
169
445
  });
170
446
 
171
- describe("when the component's init method returns an object", function() {
172
- it("attaches the returned object (instead of the component) to Jelly.observers", function() {
447
+ describe("when the component's init method returns an object", function () {
448
+ it("attaches the returned object (instead of the component) to Jelly.observers", function () {
173
449
  var observer = new Object();
174
450
  var component = {
175
- init: function() {
451
+ init:function () {
176
452
  return observer;
177
453
  }
178
454
  };
@@ -184,38 +460,38 @@ describe("Jelly", function() {
184
460
  });
185
461
  });
186
462
 
187
- describe(".Observers.notify", function() {
188
- beforeEach(function() {
463
+ describe(".Observers.notify", function () {
464
+ beforeEach(function () {
189
465
  Jelly.Pages.add("MyPage", {
190
- on_my_method : function() {
466
+ on_my_method:function () {
191
467
  }
192
468
  });
193
469
  Jelly.attach("Jelly.Page", "MyPage", "index");
194
470
  });
195
471
 
196
- describe("when bound to the default Jelly.observers collection", function() {
197
- describe("the active page object", function() {
198
- describe("when the notify method is defined on the page", function() {
199
- it("should call the notify method on the page", function() {
472
+ describe("when bound to the default Jelly.observers collection", function () {
473
+ describe("the active page object", function () {
474
+ describe("when the notify method is defined on the page", function () {
475
+ it("should call the notify method on the page", function () {
200
476
  spyOn(page, 'on_my_method');
201
477
  Jelly.notifyObservers("on_my_method", "arg1", "arg2");
202
478
  expect(page.on_my_method).wasCalled();
203
479
  expect(page.on_my_method).wasCalledWith('arg1', 'arg2');
204
480
  });
205
481
 
206
- describe("when there are attached components", function() {
207
- it("calls the notify methods in the order of the attached components", function() {
482
+ describe("when there are attached components", function () {
483
+ it("calls the notify methods in the order of the attached components", function () {
208
484
  var component = {
209
- on_my_method: function() {
485
+ on_my_method:function () {
210
486
  }
211
487
  };
212
488
  Jelly.attach(component);
213
489
 
214
490
  var functionsCalledInOrder = [];
215
- spyOn(page, 'on_my_method').andCallFake(function() {
491
+ spyOn(page, 'on_my_method').andCallFake(function () {
216
492
  functionsCalledInOrder.push("page");
217
493
  });
218
- spyOn(component, 'on_my_method').andCallFake(function() {
494
+ spyOn(component, 'on_my_method').andCallFake(function () {
219
495
  functionsCalledInOrder.push("component");
220
496
  });
221
497
  Jelly.notifyObservers("on_my_method", "arg1", "arg2");
@@ -228,32 +504,32 @@ describe("Jelly", function() {
228
504
  });
229
505
  });
230
506
 
231
- describe("when the page object does not define the notify method", function() {
232
- it("does not blow up", function() {
507
+ describe("when the page object does not define the notify method", function () {
508
+ it("does not blow up", function () {
233
509
  expect(page.on_my_undefined_method).toBe(undefined);
234
510
  Jelly.notifyObservers("on_my_undefined_method", "arg1", "arg2");
235
511
  });
236
512
  });
237
513
  });
238
514
 
239
- describe("when the 'on' parameter is present", function() {
240
- beforeEach(function() {
241
- GlobalObject = {on_my_method: function() {
515
+ describe("when the 'on' parameter is present", function () {
516
+ beforeEach(function () {
517
+ GlobalObject = {on_my_method:function () {
242
518
  }};
243
- GlobalObject.secondObject = {on_my_method: function() {
519
+ GlobalObject.secondObject = {on_my_method:function () {
244
520
  }};
245
521
  });
246
522
 
247
- afterEach(function() {
523
+ afterEach(function () {
248
524
  delete GlobalObject;
249
525
  });
250
526
  });
251
527
  });
252
528
 
253
- describe("when bound to an array of custom observers", function() {
254
- it("notifies the given observers and not the existing Jelly.observers, unless in the list of observers", function() {
529
+ describe("when bound to an array of custom observers", function () {
530
+ it("notifies the given observers and not the existing Jelly.observers, unless in the list of observers", function () {
255
531
  var component = {
256
- on_my_method: function() {
532
+ on_my_method:function () {
257
533
  }
258
534
  };
259
535
  Jelly.attach("Jelly.Page", "MyPage", "index");
@@ -262,10 +538,10 @@ describe("Jelly", function() {
262
538
  spyOn(page, 'on_my_method');
263
539
  spyOn(component, 'on_my_method');
264
540
 
265
- var customObserver1 = {on_my_method: function() {
541
+ var customObserver1 = {on_my_method:function () {
266
542
  }};
267
543
  spyOn(customObserver1, 'on_my_method');
268
- var customObserver2 = {on_my_method: function() {
544
+ var customObserver2 = {on_my_method:function () {
269
545
  }};
270
546
  spyOn(customObserver2, 'on_my_method');
271
547
 
@@ -281,10 +557,10 @@ describe("Jelly", function() {
281
557
  });
282
558
  });
283
559
 
284
- describe("an observer listening to on_notify", function() {
285
- it("receives a notify instruction", function() {
560
+ describe("an observer listening to on_notify", function () {
561
+ it("receives a notify instruction", function () {
286
562
  var observer = {
287
- on_notify: function() {
563
+ on_notify:function () {
288
564
  }
289
565
  };
290
566
  spyOn(observer, 'on_notify');
@@ -295,23 +571,23 @@ describe("Jelly", function() {
295
571
  });
296
572
  });
297
573
 
298
- describe("an observer listening to the notify method", function() {
574
+ describe("an observer listening to the notify method", function () {
299
575
  var observer;
300
- beforeEach(function() {
576
+ beforeEach(function () {
301
577
  observer = {
302
- on_my_method: function() {
578
+ on_my_method:function () {
303
579
  }
304
580
  };
305
581
  Jelly.attach(observer);
306
582
  expect(Jelly.observers).toContain(observer);
307
583
  });
308
584
 
309
- describe("when the observer does not have a detach method defined", function() {
310
- beforeEach(function() {
585
+ describe("when the observer does not have a detach method defined", function () {
586
+ beforeEach(function () {
311
587
  expect(observer.detach).toBe(undefined);
312
588
  });
313
589
 
314
- it("leaves the observer in Jelly.observers and calls the notify method on the observer", function() {
590
+ it("leaves the observer in Jelly.observers and calls the notify method on the observer", function () {
315
591
  spyOn(observer, "on_my_method");
316
592
 
317
593
  Jelly.notifyObservers("on_my_method");
@@ -320,21 +596,21 @@ describe("Jelly", function() {
320
596
  });
321
597
  });
322
598
 
323
- describe("when the observer a detach method defined", function() {
324
- describe("when the detach method is truthy", function() {
599
+ describe("when the observer a detach method defined", function () {
600
+ describe("when the detach method is truthy", function () {
325
601
  var anotherObserver;
326
- beforeEach(function() {
327
- observer.detach = function() {
602
+ beforeEach(function () {
603
+ observer.detach = function () {
328
604
  return true;
329
605
  };
330
606
  anotherObserver = {
331
- on_my_method: function() {
607
+ on_my_method:function () {
332
608
  }
333
609
  };
334
610
  Jelly.attach(anotherObserver);
335
611
  });
336
612
 
337
- it("removes observer in Jelly.observers, does not call the notify method on the observer, and calls the other observers", function() {
613
+ it("removes observer in Jelly.observers, does not call the notify method on the observer, and calls the other observers", function () {
338
614
  spyOn(observer, "on_my_method");
339
615
  spyOn(anotherObserver, "on_my_method");
340
616
 
@@ -345,14 +621,14 @@ describe("Jelly", function() {
345
621
  });
346
622
  });
347
623
 
348
- describe("when the detach method is falsy", function() {
349
- beforeEach(function() {
350
- observer.detach = function() {
624
+ describe("when the detach method is falsy", function () {
625
+ beforeEach(function () {
626
+ observer.detach = function () {
351
627
  return undefined;
352
628
  }
353
629
  });
354
630
 
355
- it("leaves the observer in Jelly.observers and calls the notify method on the observer", function() {
631
+ it("leaves the observer in Jelly.observers and calls the notify method on the observer", function () {
356
632
  spyOn(observer, "on_my_method");
357
633
 
358
634
  Jelly.notifyObservers("on_my_method");
@@ -365,55 +641,55 @@ describe("Jelly", function() {
365
641
  });
366
642
  });
367
643
 
368
- describe("Jelly.Page", function() {
644
+ describe("Jelly.Page", function () {
369
645
  var our_token;
370
646
 
371
- beforeEach(function() {
647
+ beforeEach(function () {
372
648
  spyOn($, 'ajax');
373
649
  our_token = "authenticity token";
374
650
  window._token = our_token;
375
651
  Jelly.init();
376
652
  });
377
653
 
378
- describe(".init", function() {
379
- beforeEach(function() {
654
+ describe(".init", function () {
655
+ beforeEach(function () {
380
656
  Jelly.Pages.add("DefinedComponent", {
381
- baz : function() {
657
+ baz:function () {
382
658
  },
383
- all : function() {
659
+ all:function () {
384
660
  },
385
- show: function() {
661
+ show:function () {
386
662
  }
387
663
  });
388
664
  spyOn(Jelly.Pages.all["DefinedComponent"], "show");
389
665
  });
390
666
 
391
- afterEach(function() {
667
+ afterEach(function () {
392
668
  delete Jelly.Pages.all["DefinedComponent"];
393
669
  });
394
670
 
395
- describe("when the passed-in controllerName is defined", function() {
396
- describe("when the actionName is defined", function() {
397
- it("invokes the page-specific method", function() {
671
+ describe("when the passed-in controllerName is defined", function () {
672
+ describe("when the actionName is defined", function () {
673
+ it("invokes the page-specific method", function () {
398
674
  var foobar = Jelly.Pages.all["DefinedComponent"];
399
675
  expect(foobar.show).wasNotCalled();
400
676
  Jelly.Page.init("DefinedComponent", "show");
401
677
  expect(foobar.show).wasCalled();
402
678
  });
403
679
 
404
- describe("when the 'all' method is defined", function() {
680
+ describe("when the 'all' method is defined", function () {
405
681
  var invokedMethods;
406
- beforeEach(function() {
682
+ beforeEach(function () {
407
683
  invokedMethods = [];
408
- spyOn(Jelly.Pages.all["DefinedComponent"], "all").andCallFake(function() {
684
+ spyOn(Jelly.Pages.all["DefinedComponent"], "all").andCallFake(function () {
409
685
  invokedMethods.push("all");
410
686
  });
411
- spyOn(Jelly.Pages.all["DefinedComponent"], "baz").andCallFake(function() {
687
+ spyOn(Jelly.Pages.all["DefinedComponent"], "baz").andCallFake(function () {
412
688
  invokedMethods.push("baz");
413
689
  });
414
690
  });
415
691
 
416
- it("invokes the all method before invoking the page-specific method", function() {
692
+ it("invokes the all method before invoking the page-specific method", function () {
417
693
  expect(invokedMethods).toEqual([]);
418
694
  Jelly.Page.init("DefinedComponent", "baz");
419
695
  expect(invokedMethods).toEqual(['all', 'baz']);
@@ -421,22 +697,22 @@ describe("Jelly.Page", function() {
421
697
  });
422
698
  });
423
699
 
424
- describe("when the actionName is not defined", function() {
425
- it("does not blow up", function() {
700
+ describe("when the actionName is not defined", function () {
701
+ it("does not blow up", function () {
426
702
  expect(Jelly.Pages.all["DefinedComponent"].easterBunny).toEqual(undefined);
427
703
  Jelly.Page.init("DefinedComponent", "easterBunny");
428
704
  });
429
705
 
430
- describe("when the 'all' method is defined", function() {
706
+ describe("when the 'all' method is defined", function () {
431
707
  var invokedMethods;
432
- beforeEach(function() {
708
+ beforeEach(function () {
433
709
  invokedMethods = [];
434
- Jelly.Pages.all["DefinedComponent"].all = function() {
710
+ Jelly.Pages.all["DefinedComponent"].all = function () {
435
711
  invokedMethods.push("all");
436
712
  };
437
713
  });
438
714
 
439
- it("invokes the all method", function() {
715
+ it("invokes the all method", function () {
440
716
  expect(Jelly.Pages.all["DefinedComponent"].easterBunny).toEqual(undefined);
441
717
  expect(invokedMethods).toEqual([]);
442
718
  Jelly.Page.init("DefinedComponent", "easterBunny");
@@ -446,8 +722,8 @@ describe("Jelly.Page", function() {
446
722
  });
447
723
  });
448
724
 
449
- describe("when the passed-in controllerName is not defined", function() {
450
- it("does nothing and does not cause an error", function() {
725
+ describe("when the passed-in controllerName is not defined", function () {
726
+ it("does nothing and does not cause an error", function () {
451
727
  expect(Jelly.Pages.all["UndefinedComponent"]).toEqual(undefined);
452
728
  Jelly.Page.init("UndefinedComponent", "easterBunny");
453
729
  });
@@ -455,10 +731,10 @@ describe("Jelly.Page", function() {
455
731
  });
456
732
  });
457
733
 
458
- describe("Jelly.Location", function() {
734
+ describe("Jelly.Location", function () {
459
735
  var our_token, originalTop;
460
736
 
461
- beforeEach(function() {
737
+ beforeEach(function () {
462
738
  spyOn($, 'ajax');
463
739
  our_token = "authenticity token";
464
740
  window._token = our_token;
@@ -466,13 +742,13 @@ describe("Jelly.Location", function() {
466
742
  originalTop = window.top;
467
743
  });
468
744
 
469
- afterEach(function() {
745
+ afterEach(function () {
470
746
  window.top = originalTop;
471
747
  });
472
748
 
473
- describe(".on_redirect", function() {
474
- it("sets top.location.href to the given location", function() {
475
- var window = {top: {location: {}}};
749
+ describe(".on_redirect", function () {
750
+ it("sets top.location.href to the given location", function () {
751
+ var window = {top:{location:{}}};
476
752
  spyOn(Jelly.Location, "window").andReturn(window);
477
753
  Jelly.Location.on_redirect("http://mars.com");
478
754
  expect(window.top.location.href).toEqual("http://mars.com");
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: honkster-jelly
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.13.0
5
+ version: 0.13.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Pivotal Labs, Inc