あなたの誓いを守ってください。 ノードとの関係

誓いは美しいものです。 「LESS」(および「less.js」)の開発で名声を得たAlexis Sellirは 、非同期動作によって駆動されるNode.JSでの開発用フレームワークVowsのリリースにより、オープンソースのスターになり始めています。



画像



このようなBDD仕様を入力に与えると:

  1. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  2. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  3. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  4. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  5. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  6. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  7. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  8. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  9. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  10. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  11. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  12. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  13. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  14. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  15. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  16. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  17. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  18. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  19. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  20. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  21. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  22. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it



  23. // division-by-zero-test.js var vows = require ( 'vows' ) , assert = require ( 'assert' ) ; // Create a Test Suite vows. describe ( 'Division by Zero' ) . addBatch ( { 'when dividing a number by zero' : { topic : function ( ) { return 42 / 0 } , 'we get Infinity' : function ( topic ) { assert. equal ( topic , Infinity ) ; } } , 'but when dividing zero by zero' : { topic : function ( ) { return 0 / 0 } , 'we get a value which' : { 'is not a number' : function ( topic ) { assert. isNaN ( topic ) ; } , 'is not equal to itself' : function ( topic ) { assert. notEqual ( topic , topic ) ; } } } } ) . run ( ) ; // Run it







次に、出力で完全に読み取り可能なレポートを取得します。

排気



マクロを使用すると、次のような便利なDSL構文になります。

  1. { 'GET /' {
  2. トピック api。 get '/'
  3. 「200 OKで応答する」 assertStatus 200
  4. }
  5. 「POST /」 {
  6. トピック api。 投稿 '/'
  7. 「許可されていない405メソッドで応答する」 assertStatus 405
  8. }
  9. 「GET /リソース(APIキーなし)」 {
  10. トピック api。 get '/ resources'
  11. 「403 Forbiddenで応答する」 assertStatus 403
  12. }
  13. 「GET /リソース?Apikey = af816e859c249fe」
  14. トピック api。 get '/ resources?apikey = af816e859c249fe'
  15. ' shoud return a 200 OK' assertStatus 200
  16. 「リソースのリストを返す必要があります」 function res {
  17. アサートします。 isArray res。body ;
  18. }
  19. }
  20. }
  21. //またはさらに
  22. {
  23. 「GET /」 respondsWith 200
  24. 「POST /」 respondsWith 405
  25. 「GET /リソース(キーなし)」 respondsWith 403
  26. }




プロジェクトのWebサイトには、インストールプロセス、使用例などの詳細が記載されています。 ところで、このサイトはHTML5マークアップを使用して非常によくできています。



翻訳者から:英語の記事のタイトルは、プロジェクトの名前-Vows(oaths)に勝ります。



All Articles