@@ -30,6 +30,7 @@ var swaggerSpec = require('../../util/spec');
30
30
var spec = require ( 'swagger-tools' ) . specs . v2 ;
31
31
var inquirer = require ( 'inquirer' ) ;
32
32
33
+ var LANGUAGE = [ 'js' , 'rb' ] ;
33
34
var FRAMEWORKS = {
34
35
connect : { source : 'connect' } ,
35
36
express : { source : 'connect' , overlay : 'express' } ,
@@ -61,6 +62,8 @@ module.exports = {
61
62
read : readProject ,
62
63
assertiontypes : TEST_ASSERTION_TYPES ,
63
64
testmodules : TEST_MODULES ,
65
+ lang : LANGUAGE ,
66
+
64
67
65
68
// for testing stub generating
66
69
generateTest : testGenerate
@@ -77,8 +80,9 @@ function create(name, options, cb) {
77
80
}
78
81
79
82
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
+
82
86
}
83
87
84
88
if ( options . framework && ! FRAMEWORKS [ options . framework ] ) {
@@ -220,6 +224,14 @@ function test(directory, options, cb) {
220
224
if ( options . mock ) {
221
225
process . env . swagger_mockMode = true ;
222
226
}
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
+
223
235
mocha . run ( function ( failures ) {
224
236
process . exit ( failures ) ;
225
237
} ) ;
@@ -456,7 +468,8 @@ function testGenerate(directory, options, cb) {
456
468
var config = {
457
469
pathName : desiredPaths ,
458
470
testModule : testModule ,
459
- assertionFormat : assertionFormat
471
+ assertionFormat : assertionFormat ,
472
+ lang : options . lang
460
473
} ;
461
474
462
475
// pass list of paths targeted for load testing
@@ -523,17 +536,16 @@ function testGenerate(directory, options, cb) {
523
536
}
524
537
}
525
538
} , 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
- }
539
+ async . each ( filteredResult , function ( file , cb ) {
540
+ if ( file . name === '.env' ) {
541
+ fs . outputFile ( path . join ( directory , file . name ) , file . test , cb ) ;
542
+ } else {
543
+ fs . outputFile ( path . join ( directory , '/test/api/client' , file . name ) , file . test . replace ( / x - e n u m / g, "enum" ) , cb ) ;
544
+ }
545
+ } , function ( err ) {
546
+ if ( runInstall ) {
547
+ installDependencies ( directory , 'Success! You may now run your tests.' , cb ) ;
548
+ }
537
549
} ) ;
538
550
} ) ;
539
551
} ) ;
0 commit comments