jsのrspecがあったようなので試してみた。(JSpec)

JavaScript Behavior Driven Development (BDD) With JSpec
http://vision-media.ca/resources/javascript/javascript-behavior-driven-development-bdd-with-jspec

git clone git://github.com/visionmedia/jspec.git

gitで取ってきて下記のjsテストしてみたけど、まだ動かないみたい。

var Cart = function (){
  this.productList = new Array();
};
Cart.prototype = {
  products: function () {
    return this.productList.length;
  },
  addProduct: function (product) {
    this.product.push(product);
  }
}

with (JSpec('shopping cart')) {                         
  before_each (function(){            
    this.cart = new Cart();
  });                                 

  it ('Should have no products to begin with', function(){
    this.cart.products.should_equal(0);
  });                                 

  it ('Should add products correctly', function(){      
    this.cart.addProduct('cookies');
    this.cart.addProduct('more cookies');
    this.cart.addProduct('lots of cookies!!!');
    this.cart.products.should_equal(3);
  });                                                               
}

this.cart.productsがとれない。
JSpecSuiteのstoreがまだ実装されていないようだ。今後に期待。
 
ちょうどWSHのテストに使えるjsを考えていたけど、jspecを移植するかな。
3年くらい前はjsのテストにTest.Moreを使っていたけど、いまはどうなったんだろう?