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
|
describe "AutoCollection", ->
subject = null
beforeEach ->
subject = csx.AutoCollection
describe ".install", ->
it "installs a categories collection", ->
subject.install('Category', 'categories', [id: 1, name: 'cakes'])
collection = csx.Collections.Category
expect(collection).not.toBe(undefined)
expect(collection.length).toEqual(1)
expect(collection.first().get('name')).toEqual('cakes')
it "binds the proper model", ->
subject.install('Category', 'categories', [])
expect(csx.Collections.Category.model).toEqual(csx.Models.Category)
it "binds the proper url", ->
subject.install('Cake', 'cakes', [])
expect(csx.Collections.Cake.url).toEqual('/api/v1/cakes')
it "works for models that do not map to a backbone model", ->
subject.install('Tag', 'acts_as_taggable_on_tags', [])
expect(csx.Collections.Tag.model).toEqual(Backbone.Model)
expect(csx.Collections.Tag.url).toEqual(undefined)
|