F1e3ab214a976a39cfd713bc93deb10f

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

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 !

Your refactoring





Format Copy from initial code

or Cancel