o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1357328628.126843: @value"I"{I" class:EFI"ProcessedAsset;FI"logical_path;FI"resourcy_spec.js;TI" pathname;FI"M/Users/jejacks0n/Projects/resourcy/spec/javascripts/resourcy_spec.coffee;FI"content_type;FI"application/javascript;FI" mtime;FI"2013-01-04T12:43:47-07:00;FI" length;Fi4I" digest;F"%862a988cf093899ae5209053b69e7a25I" source;FI"4(function() { describe("Resourcy", function() { beforeEach(function() { return Resourcy.removeAll(); }); describe(".resources (creating a plural resource)", function() { beforeEach(function() { return this.resource = Resourcy.resources('blogs/:blog_id/posts'); }); it("returns a resource", function() { return expect(typeof this.resource).toBe('object'); }); it("sets information on the resource", function() { expect(this.resource.pathvars).toEqual(['blog_id']); expect(this.resource.actions).toEqual({}); expect(this.resource.singular).toBe(false); return expect(this.resource.name).toBe('posts'); }); it("has an add, remove, and describe method", function() { expect(typeof this.resource.add).toBe('function'); expect(typeof this.resource.remove).toBe('function'); return expect(typeof this.resource.describe).toBe('function'); }); return it("can find an existing resource and return it", function() { var r2; r2 = Resourcy.resources('blogs/:blog_id/posts'); return expect(r2).toBe(this.resource); }); }); describe(".resource (creating a singular resource)", function() { beforeEach(function() { return this.resource = Resourcy.resource('blogs/:blog_id/owner'); }); it("returns a resource", function() { return expect(typeof this.resource).toBe('object'); }); it("sets information on the resource", function() { expect(this.resource.pathvars).toEqual(['blog_id']); expect(this.resource.actions).toEqual({}); expect(this.resource.singular).toBe(true); return expect(this.resource.name).toBe('owner'); }); it("has an add, remove, and describe method", function() { expect(typeof this.resource.add).toBe('function'); expect(typeof this.resource.remove).toBe('function'); return expect(typeof this.resource.describe).toBe('function'); }); return it("can find an existing resource and return it", function() { var r2; r2 = Resourcy.resource('blogs/:blog_id/owner'); return expect(r2).toBe(this.resource); }); }); describe(".routes", function() { beforeEach(function() { Resourcy.resources('blogs/:blog_id/posts'); return Resourcy.resource('blogs/:blog_id/owner'); }); it("returns an object of registered resources", function() { return expect(Resourcy.routes()).toEqual({ owner: [], posts: [] }); }); return it("calls describe on all the resources", function() { spyOn(Resourcy.resources('blogs/:blog_id/posts'), 'describe').andCallFake(function() { return ['posts => foo']; }); spyOn(Resourcy.resources('blogs/:blog_id/owner'), 'describe').andCallFake(function() { return ['owner => foo']; }); return expect(Resourcy.routes()).toEqual({ owner: ['owner => foo'], posts: ['posts => foo'] }); }); }); describe(".noConflict", function() { return it("removes Resourcy", function() { Resourcy.noConflict(); expect(window.Resourcy).toBeUndefined(); return window.Resourcy = window.R; }); }); describe("plural resources", function() { beforeEach(function() { this.resource = Resourcy.resources('blogs/:blog_id/posts'); return this.callback = function() { return 'callback'; }; }); describe("#add", function() { it("accepts an object, and adds to the actions", function() { this.resource.add({ index: this.callback }); return expect(this.resource.actions.index).toBe(this.callback); }); it("accepts an string and callback, and adds to the actions", function() { this.resource.add('put:activate', this.callback); return expect(this.resource.actions.put['activate']).toBe(this.callback); }); it("doesn't allow adding the same action more than once", function() { var _this = this; this.resource.add({ index: this.callback }); return expect(function() { return _this.resource.add({ index: _this.callback }); }).toThrow("The index action already exists on the 'posts' resource. Try removing it first."); }); return it("returns itself for chaining", function() { return expect(this.resource.add('put:activate', this.callback)).toBe(this.resource); }); }); describe("#remove", function() { beforeEach(function() { this.resource.add('index', this.callback); return this.resource.add('put:activate', this.callback); }); it("removes the action", function() { expect(this.resource.actions.index).toBe(this.callback); expect(this.resource.actions.put['activate']).toBe(this.callback); this.resource.remove('index'); this.resource.remove('put:activate'); expect(this.resource.actions.index).toBeUndefined(); return expect(this.resource.actions.put['activate']).toBeUndefined(); }); return it("returns itself for chaining", function() { return expect(this.resource.remove('index')).toBe(this.resource); }); }); describe("#removeAll", function() { beforeEach(function() { this.resource.add('index', this.callback); return this.resource.add('put:activate', this.callback); }); it("clears all actions", function() { expect(this.resource.actions.index).toBe(this.callback); expect(this.resource.actions.put['activate']).toBe(this.callback); this.resource.removeAll(); return expect(this.resource.actions).toEqual({}); }); return it("returns itself for chaining", function() { return expect(this.resource.removeAll()).toBe(this.resource); }); }); return describe("#describe", function() { beforeEach(function() { this.resource.add('index', this.callback); return this.resource.add('put:activate', this.callback); }); return it("returns an array describing the resource actions", function() { return expect(this.resource.describe()).toEqual(['blogs/:blog_id/posts/activate PUT => posts#activate', 'blogs/:blog_id/posts GET => posts#index']); }); }); }); return describe("singular resources", function() { beforeEach(function() { this.resource = Resourcy.resource('blogs/:blog_id/owner'); return this.callback = function() { return 'callback'; }; }); describe("#add", function() { return it("doesn't allow adding the index action", function() { var _this = this; return expect(function() { return _this.resource.add('index'); }).toThrow("Adding index to 'owner' isn't possible (singular resource)."); }); }); return describe("#describe", function() { beforeEach(function() { this.resource.add('show', this.callback); return this.resource.add('put:activate', this.callback); }); return it("returns an array describing the resource actions", function() { return expect(this.resource.describe()).toEqual(['blogs/:blog_id/owner/activate PUT => owner#activate', 'blogs/:blog_id/owner GET => owner#show']); }); }); }); }); }).call(this); ;TI"dependency_digest;F"%252e6a29d91234a8c0968d12ab6e64a5I"required_paths;F[I"T/Users/jejacks0n/Projects/resourcy/vendor/assets/javascripts/resourcy.js.coffee;FI"M/Users/jejacks0n/Projects/resourcy/spec/javascripts/resourcy_spec.coffee;FI"dependency_paths;F[{I" path;FI"M/Users/jejacks0n/Projects/resourcy/spec/javascripts/resourcy_spec.coffee;FI" mtime;FI"2013-01-04T12:43:47-07:00;FI" digest;F"%58a18a6b80a68ad0cf786beccaba6d37{I" path;FI"T/Users/jejacks0n/Projects/resourcy/vendor/assets/javascripts/resourcy.js.coffee;FI" mtime;FI"2012-10-23T10:52:41-06:00;FI" digest;F"%fa23f1823eb271510001413a28ecd798I" _version;F"%9f3b95dd7ea3030dc35985c0a8020862