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(){} )