11/*global describe, beforeEach, it */
22'use strict' ;
3+
34var path = require ( 'path' ) ;
5+ var assert = require ( 'yeoman-generator' ) . assert ;
46var helpers = require ( 'yeoman-generator' ) . test ;
57
68describe ( 'metalsmith generator' , function ( ) {
7- beforeEach ( function ( done ) {
8- helpers . testDirectory ( path . join ( __dirname , 'temp' ) , function ( err ) {
9- if ( err ) {
10- return done ( err ) ;
11- }
129
13- this . app = helpers . createGenerator ( 'metalsmith:app' , [
14- '../../app'
15- ] ) ;
16- done ( ) ;
17- } . bind ( this ) ) ;
10+ before ( function ( done ) {
11+ helpers . run ( path . join ( __dirname , '../app' ) )
12+ . inDir ( path . join ( __dirname , './temp' ) )
13+ . withOptions ( {
14+ 'skip-install-message' : true ,
15+ 'skip-install' : true ,
16+ 'skip-welcome-message' : true ,
17+ 'skip-message' : true
18+ } )
19+ . withPrompt ( {
20+ msTitle : 'Metalsmith Blog' ,
21+ msDesc : 'My Metalsmith-Powered Site' ,
22+ msAuthor : 'Metal Smith' ,
23+ msGithubUser : 'metalsmith' ,
24+ msPlugins : [
25+ 'metalsmith-ignore' ,
26+ 'metalsmith-drafts' ,
27+ 'metalsmith-templates' ,
28+ 'metalsmith-markdown' ,
29+ 'metalsmith-permalinks' ,
30+ 'metalsmith-collections'
31+ ] ,
32+ templateEngine : 'swig' ,
33+ permalinksPattern : ':title' ,
34+ } )
35+ . on ( 'end' , done ) ;
1836 } ) ;
1937
20- it ( 'creates expected files' , function ( done ) {
21- var expected = [
38+ it ( 'creates files' , function ( ) {
39+ assert . file ( [
2240 '_layouts/post.html' ,
2341 '_posts/2012-08-20-first-post.md' ,
2442 '_posts/2012-08-23-second-post.md' ,
@@ -29,28 +47,7 @@ describe('metalsmith generator', function () {
2947 'metalsmith.json' ,
3048 'Makefile' ,
3149 'README.md'
32- ] ;
33-
34- helpers . mockPrompt ( this . app , {
35- msTitle : 'Metalsmith Blog' ,
36- msDesc : 'My Metalsmith-Powered Site' ,
37- msAuthor : 'Metal Smith' ,
38- msGithubUser : 'metalsmith' ,
39- msPlugins : [
40- 'metalsmith-ignore' ,
41- 'metalsmith-drafts' ,
42- 'metalsmith-templates' ,
43- 'metalsmith-markdown' ,
44- 'metalsmith-permalinks' ,
45- 'metalsmith-collections'
46- ] ,
47- templateEngine : 'swig' ,
48- permalinksPattern : ':title' ,
49- } ) ;
50- this . app . options [ 'skip-install' ] = true ;
51- this . app . run ( { } , function ( ) {
52- helpers . assertFile ( expected ) ;
53- done ( ) ;
54- } ) ;
50+ ] ) ;
5551 } ) ;
52+
5653} ) ;
0 commit comments