Skip to content
Mickael Daniel edited this page Jan 30, 2013 · 2 revisions

test-fetch

yeoman.generators.Base

generator.install(name).

this.dummy.install('backbone', function(err) {
  fs.stat('components/backbone', done);
});

generator.tarball(tarball, destination, cb)

generator.fetch(url, destination, cb)

should allow the fething of a single file.

this.dummy.fetch('https://raw.github.com/yeoman/generators/master/README.md', './some/path/README.md', function (err) {
  if (err) {
    return done(err);
  }
  fs.stat('./some/path/README.md', done);
});

generator.remote(user, repo, branch, cb)

should remotely fetch a package on github.

this.dummy.remote('yeoman', 'generators', done);

should have the result cached internally into a _cache folder.

fs.stat(path.join(this.homedir, '.yeoman/cache/yeoman/generators/master'), done);

should invoke cb with a remote object to interract with the downloaded package.

this.dummy.remote('yeoman', 'generators', function (err, remote) {
  if (err) {
    return done(err);
  }

  ['copy', 'template', 'directory'].forEach(function (method) {
    assert.equal(typeof remote[method], 'function');
  });

  done();
});