Skip to content

Instantly share code, notes, and snippets.

@tj
Created April 9, 2009 06:23
Show Gist options
  • Save tj/92283 to your computer and use it in GitHub Desktop.
Save tj/92283 to your computer and use it in GitHub Desktop.
// --- Screw.Unit
describe('Person', function(){
var person
before(function(){
person = new Person
})
describe('.addPet', function(){
it('should add pets', function(){
person.addPet('foo').addPet('bar')
expect(person.pets.length).to(equal, 2)
})
})
})
// --- jsUnitTest
new Test.Unit.Runner({
setup : function(){
this.person = new Person
},
// no nesting ? ...
testPersonAddPet : function(){
this.person.addPet('foo').addPet('bar')
assertEqual(2, this.person.pets.length)
}
})
// --- YUI Test
test = new YAHOO.tool.TestCase({
name: "Person",
setUp : function () {
this.person = new Person
},
testAddPet: function () {
Assert = YAHOO.util.Assert
this.person.addPet('foo').addPet('bar')
Assert.areEqual(2, this.person.pets.length)
},
});
// --- JSpec
describe 'Person'
before
person = new Person
end
describe '.addPet'
it 'should add pets'
person.addPet('foo').addPet('bar')
person.should.have 2, 'pets'
end
end
end
// OR with grammar-less option
describe('Person', function(){
before(function(){
person = new Person
})
describe('.addPet', function(){
it ('should add pets', function(){
person.addPet('foo').addPet('bar')
expect(person).to(have, 2, 'pets')
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment