UNPKG

specify-assertions

Version:

Beautiful assertion library.

219 lines (144 loc) 6.47 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Specify (assertions) Index</title> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css"> <link type="text/css" rel="stylesheet" href="styles/site.cerulean.css"> </head> <body> <div class="container-fluid"> <div class="navbar navbar-fixed-top "> <div class="navbar-inner"> <a class="brand" href="index.html">Specify (assertions)</a> <ul class="nav"> <li class="dropdown"> <a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a> <ul class="dropdown-menu "> <li> <a href="divergence.Divergence_.html">Divergence</a> </li> </ul> </li> <li class="dropdown"> <a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a> <ul class="dropdown-menu "> <li> <a href="divergence.html">specify-assertions/lib/divergence</a> </li> <li> <a href="index_.html">specify-assertions/lib/index</a> </li> <li> <a href="validations.html">specify-assertions/lib/validations</a> </li> </ul> </li> </ul> </div> </div> <div class="row-fluid"> <div class="span8"> <div id="main"> <span class="page-title">Index</span> <section> <article><h1>specify-assertions</h1><p><a href="https://travis-ci.org/origamitower/specify-assertions"><img src="https://img.shields.io/travis/origamitower/specify-assertions/master.svg?style=flat" alt="Build status"></a> <a href="https://npmjs.org/package/specify-assertions"><img src="https://img.shields.io/npm/v/specify-assertions.svg?style=flat" alt="NPM version"></a> <a href="https://david-dm.org/origamitower/specify-assertions"><img src="https://img.shields.io/david/origamitower/specify-assertions.svg?style=flat" alt="Dependencies status"></a> <img src="https://img.shields.io/npm/l/specify-assertions.svg?style=flat&amp;label=licence" alt="Licence"> <img src="https://img.shields.io/badge/API_stability-stable-green.svg?style=flat" alt="Stable API"></p> <p>Beautiful assertion library.</p> <h2>Philosophy</h2><ul> <li><p><strong>Straight-forward</strong>: Alright should get out of your way and just let you define your tests with what you already know: plain JavaScript.</p> </li> <li><p><strong>No verbosity</strong>: We don't want <code>expect(x).to.eventually.be.boring...</code></p> </li> <li><p><strong>Helpful error messages</strong>: When things go wrong, Alright should do its best to show you exactly what's wrong and how you might fix it.</p> </li> <li><p><strong>Test-framework agnostic</strong>: Alright should work with anything that expect Errors to be thrown when assertions fail.</p> </li> <li><p><strong>Extensible</strong>: It should be easy to extend the built-in assertions with plain JavaScript.</p> </li> <li><p><strong>Work with older Browsers</strong>: Some people still need to support old IEs, Alright should work on them.</p> </li> </ul> <h2>Example</h2><p>Using the Sweet.js macros:</p> <pre class="prettyprint source lang-js"><code>var _ = require('specify-assertions') // simple assertions add(a)(b) => a + b add(a)(b) => not a + b // anything goes assertions add(a)(b) should _.equal(a + b) add(a)(b) should not _.equal(a + b) // asynchronous assertions with pure fantasy-land monads, or Promises/A+ asyncAdd(a)(b) will _.equal(a + b) asyncAdd(a)(b) will not _.equal(a + b)</code></pre><p>Using vanilla JavaScript:</p> <pre class="prettyprint source lang-js"><code>var _ = require('specify-assertions') // Use verify for synchronous assertions _.verify(add(a)(b))(_.equals(a + b)) _.verify(add(a)(b))(_.not(_.equals(a + b))) // use verifyFuture for monadic Futures, and verifyPromise for Promises/A+ _.verifyMonad(asyncAdd(a)(b))(_.equals(a + b))</code></pre><h2>Installing</h2><pre class="prettyprint source"><code>$ npm install specify-assertions</code></pre><h2>Tests</h2><pre class="prettyprint source"><code>$ npm install $ make test</code></pre><h2>Documentation</h2><pre class="prettyprint source"><code>$ npm install $ make documentation</code></pre><h2>Platform support</h2><p>This library assumes an ES5 environment, but can be easily supported in ES3 platforms by the use of shims. Just include [es5-shim][] :)</p> <h2>Licence</h2><p>Copyright (c) 2013-2014 <a href="http://www.origamitower.com">Origami Tower</a>.</p> <p>This module is part of the <a href="https://github.com/origamitower/specify">Specify framework</a>, and released under the <a href="http://origami-tower.mit-license.org/">MIT</a> licence.</p></article> </section> </div> <div class="clearfix"></div> <footer> <span class="copyright"> © 2014 Origami Tower </span> <br /> <span class="jsdoc-message"> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Thu Dec 25 2014 14:27:25 GMT-0200 (BRST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>. </span> </footer> </div> <div class="span3"> <div id="toc"></div> </div> <br clear="both"> </div> </div> <script src="scripts/sunlight.js"></script> <script src="scripts/sunlight.javascript.js"></script> <script src="scripts/sunlight-plugin.doclinks.js"></script> <script src="scripts/sunlight-plugin.linenumbers.js"></script> <script src="scripts/sunlight-plugin.menu.js"></script> <script src="scripts/jquery.min.js"></script> <script src="scripts/jquery.scrollTo.js"></script> <script src="scripts/jquery.localScroll.js"></script> <script src="scripts/bootstrap-dropdown.js"></script> <script src="scripts/toc.js"></script> <script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script> <script> $( function () { $( "#toc" ).toc( { anchorName : function(i, heading, prefix) { return $(heading).attr("id") || ( prefix + i ); }, selectors : "h1,h2,h3,h4", showAndHide : false, scrollTo : 60 } ); $( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" ); $( "#main span[id^='toc']" ).addClass( "toc-shim" ); } ); </script> </body> </html>