Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'mkuklis/master'

* mkuklis/master:
  added spec for inherit; updated jshint
  removed extra space
  added ability to inherit from other factories
  • Loading branch information...
commit aa2940410a32caedd91885af324a39e0bca705f4 2 parents d66fc8f + d34954d
@bkeepers authored
View
6,434 spec/javascripts/helpers/jshint.js
2,707 additions, 3,727 deletions not shown
View
13 spec/javascripts/rosie.spec.js
@@ -40,6 +40,17 @@ describe('Factory', function() {
});
});
+ describe('inherit', function() {
+ beforeEach(function() {
+ Factory.define('thing').attr('name', 'Thing 1');
+ Factory.define('anotherThing').inherit('thing').attr('title', 'Title 1');
+ });
+
+ it('should inherit attributes', function() {
+ expect(Factory.build('anotherThing')).toEqual({name:'Thing 1', title:'Title 1'});
+ });
+ });
+
describe('attributes', function() {
beforeEach(function() {
Factory.define('thing').attr('name', 'Thing 1');
@@ -123,4 +134,4 @@ describe('Factory', function() {
});
});
});
-});
+});
View
4 spec/javascripts/z_jshint_spec.js
@@ -1,5 +1,5 @@
describe('JSHint', function () {
- var options = {curly: true, indent: 2},
+ var options = {curly: true, indent: 2, white: false},
files = /^\/src/;
function get(path) {
@@ -39,4 +39,4 @@ describe('JSHint', function () {
}
});
-});
+});
View
10 src/rosie.js
@@ -34,6 +34,16 @@ Factory.prototype = {
build: function(attrs) {
var result = this.attributes(attrs);
return this.construct ? new this.construct(result) : result;
+ },
+
+ inherit: function(name) {
+ var factory = Factory.factories[name];
+ for(var attr in factory.attrs) {
+ if(factory.attrs.hasOwnProperty(attr)) {
+ this.attrs[attr] = factory.attrs[attr];
+ }
+ }
+ return this;
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.