@@ -30,6 +30,7 @@ var swaggerSpec = require('../../util/spec');
3030var spec = require ( 'swagger-tools' ) . specs . v2 ;
3131var inquirer = require ( 'inquirer' ) ;
3232
33+ var LANGUAGE = [ 'js' , 'rb' ] ;
3334var FRAMEWORKS = {
3435 connect : { source : 'connect' } ,
3536 express : { source : 'connect' , overlay : 'express' } ,
@@ -61,6 +62,8 @@ module.exports = {
6162 read : readProject ,
6263 assertiontypes : TEST_ASSERTION_TYPES ,
6364 testmodules : TEST_MODULES ,
65+ lang : LANGUAGE ,
66+
6467
6568 // for testing stub generating
6669 generateTest : testGenerate
@@ -77,8 +80,9 @@ function create(name, options, cb) {
7780 }
7881
7982 if ( name ) {
80- var valid = validateName ( name ) ;
81- if ( typeof valid === 'string' ) { return cb ( new Error ( valid ) ) ; }
83+ var valid = validateName ( name ) ;
84+ if ( typeof valid === 'string' ) { return cb ( new Error ( valid ) ) ; }
85+
8286 }
8387
8488 if ( options . framework && ! FRAMEWORKS [ options . framework ] ) {
@@ -220,6 +224,14 @@ function test(directory, options, cb) {
220224 if ( options . mock ) {
221225 process . env . swagger_mockMode = true ;
222226 }
227+
228+ var server_config = require ( '../../../../../config.json' )
229+ process . env . swagger_host = server_config [ options . host ] . protocol + "://" ;
230+ process . env . swagger_host += server_config [ options . host ] . host ;
231+ if ( server_config [ options . host ] . port != "" ) {
232+ process . env . swagger_host += ":" + server_config [ options . host ] . port ;
233+ }
234+
223235 mocha . run ( function ( failures ) {
224236 process . exit ( failures ) ;
225237 } ) ;
@@ -456,7 +468,8 @@ function testGenerate(directory, options, cb) {
456468 var config = {
457469 pathName : desiredPaths ,
458470 testModule : testModule ,
459- assertionFormat : assertionFormat
471+ assertionFormat : assertionFormat ,
472+ lang : options . lang
460473 } ;
461474
462475 // pass list of paths targeted for load testing
@@ -523,18 +536,9 @@ function testGenerate(directory, options, cb) {
523536 }
524537 }
525538 } , function ( filteredResult ) {
526-
527- async . each ( filteredResult , function ( file , cb ) {
528- if ( file . name === '.env' ) {
529- fs . outputFile ( path . join ( directory , file . name ) , file . test , cb ) ;
530- } else {
531- fs . outputFile ( path . join ( directory , '/test/api/client' , file . name ) , file . test , cb ) ;
532- }
533- } , function ( err ) {
534- if ( runInstall ) {
535- installDependencies ( directory , 'Success! You may now run your tests.' , cb ) ;
536- }
537- } ) ;
539+ finalResult . forEach ( function ( file ) {
540+ fs . outputFile ( path . join ( directory , '/test/api/client' , file . name ) , file . test . replace ( / x - e n u m / g, "enum" ) , cb ) ;
541+ } ) ;
538542 } ) ;
539543 } ) ;
540544 } ) ;
0 commit comments