Skip to content
Mickael Daniel edited this page Jul 29, 2012 · 1 revision

TOC

# yeoman init && yeoman build ## When I run init app with default prompts should output to stdout expected file writes.
var yeoman = helpers.run('init --force', opts);
yeoman
  // enter '\n' for both prompts, and grunt confirm
  .prompt(/Would you like to include (.+) plugins/)
  .prompt(/Where would you like it be downloaded ?/)
  .prompt(/Do you need to make any changes to the above before continuing?/)

  // check few pattern in the process stdout
  // Check app generator invoke
  .expect(/Invoke (.+)?app/)

  // top level files
  .expect(/Writing Gruntfile\.js/)
  .expect(/Writing package.json/)

  // some expected files from h5bp
  .expect(/Writing app\/index\.html/)
  .expect(/Writing app\/404\.html/)
  .expect(/Writing app\/apple-touch-icon-(.+).png/)
  .expect(/Writing app\/css\/main\.css/)
  .expect(/Writing app\/img\/\.gitignore/)
  .expect(/Writing app\/js\/main\.js/)

  // same for bootstrap
  .expect(/Writing app\/js\/vendor\/bootstrap\/bootstrap-(.+)\.js/)

  // stylesheet hook - sass:app
  .expect(/Invoke sass:app/)
  .expect(/Writing app\/css\/sass\/main\.scss/)
  .expect(/Writing app\/css\/sass\/_compass_twitter_bootstrap\.sass/)
  .expect(/Writing app\/css\/sass\/compass_twitter_bootstrap\/(.+).sass/)

  // test hook - jasmine:app
  .expect(/Invoke jasmine:app/)
  .expect(/Writing test\/index\.html/)
  .expect(/Writing test\/lib\/jasmine-[0-9\.]+\/jasmine\.css/)
  .expect(/Writing test\/lib\/jasmine-[0-9\.]+\/jasmine\.js/)
  .expect(/Writing test\/runner\/html\.js/)
  .expect(/Writing test\/runner\/headless\.js/)

  // run and done
  .end(done);

should generate index.html with bootstrap plugins.

var index = grunt.file.read('app/index.html');
assert.ok((/<!-- build:js js\/plugins.js -->/).test(index));
assert.ok((/<!-- endbuild -->/).test(index));

assert.ok(index.match('js/vendor/bootstrap/bootstrap-alert.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-dropdown.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-tooltip.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-modal.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-transition.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-button.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-popover.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-typeahead.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-carousel.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-scrollspy.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-collapse.js'));
assert.ok(index.match('js/vendor/bootstrap/bootstrap-tab.js'));

should generate an app/ directory.

fs.stat('app/', done);

should generate a spec/ directory.

fs.stat('spec/', done);

should generate a test/ directory.

fs.stat('test/', done);

should generate a Gruntfile.js file.

fs.stat('Gruntfile.js', done);
## And I run a build should run the correct set of task.
this.yeoman
  .expect(0)
  // intro clean mkdirs coffee compass usemin-handler rjs concat css img rev usemin manifest copy time
  .expect(/Running "build(:.+)?" (\(.+\) )?task/)
  .expect(/Running "clean(:.+)?" (\(.+\) )?task/)
  .expect(/Running "mkdirs(:.+)?" (\(.+\) )?task/)
  .expect(/Running "coffee(:.+)?" (\(.+\) )?task/)
  .expect(/Running "compass(:.+)?" (\(.+\) )?task/)
  .expect(/Running "usemin-handler(:.+)?" (\(.+\) )?task/)
  .expect(/Running "rjs(:.+)?" (\(.+\) )?task/)
  .expect(/Running "concat(:.+)?" (\(.+\) )?task/)
  .expect(/Running "css(:.+)?" (\(.+\) )?task/)
  .expect(/Running "img(:.+)?" (\(.+\) )?task/)
  .expect(/Running "rev(:.+)?" (\(.+\) )?task/)
  .expect(/Running "usemin(:.+)?" (\(.+\) )?task/)
  .expect(/Running "manifest(:.+)?" (\(.+\) )?task/)
  .expect(/Running "copy(:.+)?" (\(.+\) )?task/)
  .expect(/Running "time(:.+)?" (\(.+\) )?task/);
### build should output the list of task at the beginning of the build.
this.yeoman
  .expect(/intro clean mkdirs coffee compass usemin-handler rjs concat css img rev usemin manifest copy time/);
### mkdirs should copy to the staging directory.
this.yeoman
  .expect(/Copying into/)
  .expect(/Ignoring .gitignore, .ignore, .buildignore/)
  .expect(/(.+)app -> (.+)intermediate/);
### coffee should go through coffee:dist.
this.yeoman.expect(/Running "coffee:dist" \(coffee\) task/);
### compass should go through compass:dist.
this.yeoman.expect(/Running "compass:dist" \(compass\) task/);

should write to css/main.css.

this.yeoman.expect(/(overwrite|identical|create)(.+)css\/main.css/);
### img should go through img:dist.
this.yeoman.expect(/Running "img:dist" \(img\) task/);
### rjs should optimize js/main.
this.yeoman.expect(/rjs optimized module: js\/main/);
### concat should write plugins.js concat target.
this.yeoman
  .expect(/Running "concat:js\/plugins\.js" \(concat\) task/)
  .expect(/File "js\/plugins\.js" created\./);

should write amd-app.js concat target.

this.yeoman
  .expect(/Running "concat:js\/amd-app.js" \(concat\) task/)
  .expect(/File "js\/amd-app\.js" created\./);
### css should process css/main.css.
this.yeoman
  .expect(/Running "css:css\/main.css" \(css\) task/)
  .expect(/Writing css files to css\/main.css/);
### rev #### rev: should find and process the following files js/main.js >> {rev}.main.js.
this.yeoman.expect(/js\/main.js >> ([a-z0-9]+)\.main.js/i);

js/plugins.js >> {rev}.plugins.js.

this.yeoman.expect(/js\/plugins.js >> ([a-z0-9]+)\.plugins.js/i);

js/vendor/bootstrap-alert.js >> {rev}.bootstrap-alert.js.

this.yeoman.expect(/js\/vendor\/bootstrap\/bootstrap-alert.js >> ([a-z0-9]+)\.bootstrap-alert.js/i);

js/vendor/jquery-1.7.2.js >> {rev}.jquery-1.7.2.js.

this.yeoman.expect(/js\/vendor\/jquery-1\.7\.2.js >> ([a-z0-9]+)\.jquery-1\.7\.2.js/i);

js/vendor/require.js >> {rev}.require.js.

this.yeoman.expect(/js\/vendor\/require\.js >> ([a-z0-9]+)\.require\.js/i);
### usemin #### usemin: should find and replace the following files js/vendor/modernizr-2.6.1.min.js.
this.yeoman
  .expect('was <script src="js/vendor/modernizr-2.6.1.min.js')
  .expect(/now <script src="js\/vendor\/([a-z0-9]+)\.modernizr-2\.6\.1\.min\.js/i);

js/amp-app.js.

this.yeoman
  .expect('was <script src="js/amd-app.js')
  .expect(/now <script src="js\/([a-z0-9]+)\.amd-app\.js/i);

css/main.css.

this.yeoman
  .expect('was <link rel="stylesheet" href="css/main.css')
  .expect(/now <link rel="stylesheet" href="css\/([a-z0-9]+)\.main\.css/i);
### manifest should start a webserver automatically.
this.yeoman.expect('Starting static web server on port 3501');

should write to manifest.appcache.

this.yeoman
  .expect('Writing to manifest.appcache')
  .expect('This manifest was created by confess.js, http://github.com/jamesgpearce/confess');
Clone this wiki locally