このようなBDD仕様を入力に与えると:
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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構文になります。
- { 'GET /' : {
- トピック: api。 get ( '/' ) 、
- 「200 OKで応答する」 : assertStatus ( 200 )
- } 、
- 「POST /」 : {
- トピック: api。 投稿 ( '/' ) 、
- 「許可されていない405メソッドで応答する」 : assertStatus ( 405 )
- } 、
- 「GET /リソース(APIキーなし)」 : {
- トピック: api。 get ( '/ resources' ) 、
- 「403 Forbiddenで応答する」 : assertStatus ( 403 )
- } 、
- 「GET /リソース?Apikey = af816e859c249fe」
- トピック: api。 get ( '/ resources?apikey = af816e859c249fe' ) 、
- ' shoud return a 200 OK' : assertStatus ( 200 ) 、
- 「リソースのリストを返す必要があります」 : function ( res ) {
- アサートします。 isArray ( res。body ) ;
- }
- }
- }
- //またはさらに
- {
- 「GET /」 : respondsWith ( 200 ) 、
- 「POST /」 : respondsWith ( 405 ) 、
- 「GET /リソース(キーなし)」 : respondsWith ( 403 )
- }
プロジェクトのWebサイトには、インストールプロセス、使用例などの詳細が記載されています。 ところで、このサイトはHTML5マークアップを使用して非常によくできています。
翻訳者から:英語の記事のタイトルは、プロジェクトの名前-Vows(oaths)に勝ります。