js-spec

js-spec: Want to do BDD in Javascript? This aims to clone rspec (http://rspec.rubyforge.org) in javascript.

For now it's very basic, but stuff like the following works.

describe("A newly created Tic-Tac-Toe", function() {
  with (this) {
    before("each", function() {
      this.game = new TicTacToe();
    });
	
    it("should have 9 empty cells", function() {
      game.cells.should( have(9, "items") );
      game.cells.each(function(cell) {
        cell.should( be(undefined) );
      });
    });
	
    it("should have 0 players", function() {
      game.should( have(0, "players") );
    });
  }
});

Stay tuned for more :)
Ask questions, make suggestions and post bugs at http://code.google.com/p/js-spec/issues/ [Nice to see BDD spreading…]
Source: Scripteka

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s