1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
describe 'ShoppingCart' var cart before_each cart = new ShoppingCart end describe 'addProducts' it 'should add several products' cart.addProduct('cookie') cart.addProduct('icecream') cart.should.have 2, 'products' end end describe 'checkout' it 'throw an error when checking out with no products' -{ cart.clear().checkout() }.should.throw_error end end end
Refactorings
No refactoring yet !
Snippit from http://visionmedia.github.com/jspec/, trying to come up with the most readable syntax possible for the testing framework (-{} is alternative for function(){} )