Coder Social home page Coder Social logo

yeoman-assert's Introduction

yeoman-assert Build Status

yeoman-assert is extending the native Node.js assert module. Every methods in assert also is available with yeoman-assert, plus some code scaffolding related assertion helpers.

Install

$ npm install yeoman-assert

Usage

const assert = require('yeoman-assert');

assert(true);
assert.equal(1, 1);

API

assert.file()

  • path (String|Array) Path to a file.

Assert that a file exists.

assert.file('templates/user.hbs');

Assert that each files in the array exists.

assert.file(['templates/user.hbs', 'templates/user/edit.hbs']);

assert.noFile()

  • path (String|Array) Path to a file.

Assert that a file doesn't exists.

assert.noFile('templates/user.hbs');

Assert that each of an array of files doesn't exist.

assert.noFile(['templates/user.hbs', 'templates/user/edit.hbs']);

assert.fileContent()

  • file (String|Array) Path to a file.
  • reg (Regex|String) Regex or string that will be used to search the file.

Assert that a file's content matches a string.

assert.fileContent('models/user.js', 'App.User = DS.Model.extend');

Assert that a file's content matches a regex.

assert.fileContent('models/user.js', /App\.User = DS\.Model\.extend/);

Assert that each of an array of files content matches a regex or string.

assert.fileContent([
   ['models/user.js', 'App.User = DS.Model.extend'],
   ['controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/]
]);

assert.noFileContent()

  • file (String|Array) Path to a file.
  • reg (Regex|String) Regex or string that will be used to search the file.

Assert that a file's content does not match a string.

assert.noFileContent('models/user.js', 'App.User = DS.Model.extend');

Assert that a file's content does not match a regex.

assert.noFileContent('models/user.js', /App\.User = DS\.Model\.extend/);

Assert that each of an array of files content does not match a regex or string.

assert.noFileContent([
   ['models/user.js', 'App.User = DS.Model.extend'],
   ['controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/]
]);

assert.textEqual()

  • value (String) A string.
  • expected (String) The expected value of the string.

Assert that two strings are equal after standardization of newlines.

assert.textEqual('I have a yellow cat', 'I have a yellow cat');

assert.implement()

  • subject (Object) Subject implementing the façade.
  • methods (Object|Array) A façace, hash or array of keys to be implemented.

Assert an Object implements an interface.

assert.implement(fs, ['readFile']);

assert.notImplement()

  • subject (Object) Subject not implementing the methods.
  • methods (Object|Array) Hash or array of method names to be implemented.

Assert an Object doesn't implements any method of an interface.

assert.notImplement(fs, ['foo']);

assert.objectContent()

Assert an object contains at least a set of keys

var anObject = {a: 1};

assert.objectContent(anObject, {a: 2});

assert.noObjectContent()

Assert an object does not contain at least a set of keys

var anObject = {a: 1};

assert.noObjectContent(anObject, {a: 1});

assert.jsonFileContent()

Assert a JSON file contains at least a set of keys (rely of assert.objectContent())

assert.jsonFileContent('path/to/file.json', {a: 2});

assert.noJsonFileContent()

Assert a JSON file does not contain at least a set of keys (rely of assert.noObjectContent())

assert.noJsonFileContent('path/to/file.json', {a: 1});

Contribute

See the contributing docs.

License

BSD-2-Clause © Google

yeoman-assert's People

Contributors

sboudrias avatar stefanbuck avatar sindresorhus avatar fernandopasik avatar addyosmani avatar arthurvr avatar eddiemonge avatar hemanth avatar kevva avatar kierans avatar mklabs avatar n3dst4 avatar smackesey avatar stephenplusplus avatar greenkeeper[bot] avatar johnnyicarus avatar thaiat avatar

Watchers

Tane Morgan avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.