var Gallery = Backbone.Model.extend({ initialize: function() { this.dataSource = { url: "path/to/images", type: "json" }; this.timeout = 3000; }, setTimeout: function(num) { this.timeout = num; }, setUrl: function(url) { this.dataSource.url = url; } }); var myGallery = new Gallery(); myGallery.setTimeout(5000); myGallery.setUrl("my/images"); var otherGallery = new Gallery(); otherGallery.setTimeout(1000); otherGallery.setUrl("other/images"); describe('myGallery', function() { it('should have it\'s own timeout property', function() { expect(myGallery.hasOwnProperty('timeout')).toBe(true); }); it('should have timeout of 5000', function() { expect(myGallery.timeout).toEqual(5000); }); it('should have it\'s own dataSource property', function() { expect(myGallery.hasOwnProperty('dataSource')).toBe(true); }); it('should have a url of my/images', function() { expect(myGallery.dataSource.url).toEqual('my/images'); }); }); // This test fails! describe('otherGallery', function() { it('should have it\'s own timeout property', function() { expect(otherGallery.hasOwnProperty('timeout')).toBe(true); }); it('should have timeout of 5000', function() { expect(otherGallery.timeout).toEqual(1000); }); it('should have it\'s own dataSource property', function() { expect(otherGallery.hasOwnProperty('dataSource')).toBe(true); }); it('should have a url of other/images', function() { expect(otherGallery.dataSource.url).toEqual('other/images'); }); });