Skip to content

Instantly share code, notes, and snippets.

@jorgemanrubia
Created December 5, 2010 18:56
Show Gist options
  • Save jorgemanrubia/729345 to your computer and use it in GitHub Desktop.
Save jorgemanrubia/729345 to your computer and use it in GitHub Desktop.
Jasmine matcher that checks the class of an object and some expected set of properties
toBeObjectWithProperties: function(expectedClass, expectedProperties) {
var isObjectWithProperties = (this.actual instanceof expectedClass);
for(var propertyName in expectedProperties){
var expectedPropertyValue = expectedProperties[propertyName];
isObjectWithProperties = isObjectWithProperties && (this.actual[propertyName] == expectedPropertyValue);
}
return isObjectWithProperties;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment