Skip to content

Commit

Permalink
[dist] Prepare for rename to APIeasy
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Apr 18, 2011
1 parent bfadeae commit 0c737a8
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RESTeasy
# APIeasy

A fluent (i.e. chainable) syntax for generating vows tests against RESTful APIs.

Expand All @@ -9,32 +9,32 @@ A fluent (i.e. chainable) syntax for generating vows tests against RESTful APIs.
curl http://npmjs.org/install.sh | sh
</pre>

### Installing RESTeasy
### Installing APIeasy
<pre>
[sudo] npm install rest-easy
[sudo] npm install api-easy
</pre>

## Purpose
RESTeasy is designed to be a simple way to test RESTful APIs in [node.js][0] and Javascript. The primary design goal was to reduce the number of lines of test code required to fully cover all primary and edge use cases of a given API over HTTP.
APIeasy is designed to be a simple way to test RESTful APIs in [node.js][0] and Javascript. The primary design goal was to reduce the number of lines of test code required to fully cover all primary and edge use cases of a given API over HTTP.

## Getting Started
Most of the documentation for this library is available through the [annotated source code, available here][1] thanks to [jashkenas][2] and [docco][3]. If you're not feeling up for that, just keep reading here.

If you're going to use RESTeasy (and I hope you do), it's worth taking a moment to understand the way that [vows][4] manages flow control. Read up here on [vowsjs.org][4] (Under "Structure of a test suite"), or just remember vows uses this grammatical structure:
If you're going to use APIeasy (and I hope you do), it's worth taking a moment to understand the way that [vows][4] manages flow control. Read up here on [vowsjs.org][4] (Under "Structure of a test suite"), or just remember vows uses this grammatical structure:

<pre>
Suite → Batch*
Batch → Context*
Context → Topic? Vow* Context*
</pre>

Got it? Good. There is a 1-to-1 relationship between a RESTeasy suite and a vows suite; RESTeasy is essentially a simpler syntax to manage a particular set of vows-based tests that conform to this pattern:
Got it? Good. There is a 1-to-1 relationship between a APIeasy suite and a vows suite; APIeasy is essentially a simpler syntax to manage a particular set of vows-based tests that conform to this pattern:

1. Tests are performed by making HTTP requests against an API server
2. Assertions are made against the HTTP response and JSON response body
3. Rinse. Repeat.

Here's a sample of the boilerplate code that RESTeasy eliminates:
Here's a sample of the boilerplate code that APIeasy eliminates:

<pre>
var request = require('request'),
Expand Down Expand Up @@ -71,13 +71,13 @@ Here's a sample of the boilerplate code that RESTeasy eliminates:
}).export(module);
</pre>

This same code can be implemented like this using RESTeasy:
This same code can be implemented like this using APIeasy:

<pre>
var RESTeasy = require('rest-easy'),
var APIeasy = require('api-easy'),
assert = require('assert');

var suite = RESTeasy.describe('your/awesome/api');
var suite = APIeasy.describe('your/awesome/api');

suite.discuss('When using your awesome API')
.discuss('and your awesome resource')
Expand Down Expand Up @@ -105,8 +105,8 @@ This same code can be implemented like this using RESTeasy:
#### Author: [Charlie Robbins](http://nodejitsu.com)

[0]: http://nodejs.org
[1]: http://indexzero.github.com/rest-easy
[1]: http://indexzero.github.com/api-easy
[2]: http://github.com/jashkenas
[3]: http://github.com/jashkenas/docco
[4]: http://vowsjs.org
[5]: http://github.com/indexzero/rest-easy/issues
[5]: http://github.com/indexzero/api-easy/issues
20 changes: 10 additions & 10 deletions docs/rest-easy.html → docs/api-easy.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html> <html> <head> <title>rest-easy.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> rest-easy.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * rest-easy.js: Top-level include for the rest-easy module.</span>
<!DOCTYPE html> <html> <head> <title>api-easy.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> api-easy.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * api-easy.js: Top-level include for the api-easy module.</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2011, Charlie Robbins</span>
<span class="cm"> *</span>
Expand All @@ -8,11 +8,11 @@
<span class="kd">var</span> <span class="nx">qs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;querystring&#39;</span><span class="p">),</span>
<span class="nx">request</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;request&#39;</span><span class="p">),</span>
<span class="nx">vows</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;vows&#39;</span><span class="p">),</span>
<span class="nx">assert</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;assert&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>Version 0.2.0 // <em>03/22/2011</em></h3> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">version</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">];</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h2>RESTeasy.describe(text)</h2>
<span class="nx">assert</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;assert&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>Version 0.2.0 // <em>03/22/2011</em></h3> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">version</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">];</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h2>APIeasy.describe(text)</h2>

<p>This is the main (and sole) entry point for RESTeasy.
<p>This is the main (and sole) entry point for APIeasy.
It responds with an object literal that manages an
underlying vows suite. Each call to <code>RESTeasy.describe()</code>
underlying vows suite. Each call to <code>APIeasy.describe()</code>
will create a vows suite, with the corresponding <code>text</code>
passed to this method.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">describe</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">text</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>State / Context management:</h3>
Expand Down Expand Up @@ -46,7 +46,7 @@
Each call to discuss will create an object in the nested vows
structure which has that text as the key in the parent. <strong>e.g.:</strong></p>

<pre><code>RESTeasy.describe('your/awesome/api')
<pre><code>APIeasy.describe('your/awesome/api')
.use('localhost', 8080)
.discuss('When using your awesome API')
.discuss('and an awesome resource')
Expand Down Expand Up @@ -127,7 +127,7 @@

<p>The <code>.get()</code>, <code>.post()</code>, <code>.put()</code>, <code>.del()</code>, and <code>.head()</code>
methods add a new context and topic to the vows structure maintained
by this RESTeasy suite. The nuts and bolts of this are in the "private"
by this APIeasy suite. The nuts and bolts of this are in the "private"
method <code>_request()</code>.</p>

<p>Each method invocation returns the suite itself so that
Expand Down Expand Up @@ -231,7 +231,7 @@

<p>Again, since we are managing a single vows suite in this object we
should expose an easy way to export your tests to a given target without
needing to call <code>restEasySuite.suite.export(module)</code>. You should only
needing to call <code>apiEasySuite.suite.export(module)</code>. You should only
call this method once in a given test file. </p>

<p>You can also call <code>.run()</code> which will run the specified suite just
Expand Down Expand Up @@ -262,7 +262,7 @@
<p><code>_request()</code> exists for the sake of DRY and simplicity and is designed to handle
a variety of interal usage(s) exposed indirectly through the <code>.get()</code>,
<code>.post()</code>, <code>.put()</code>, <code>.del()</code> and <code>.head()</code>. Nothing to see here unless you're
interested in improving RESTeasy itself.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">_request</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="cm">/* method [uri, data, params] */</span><span class="p">)</span> <span class="p">{</span>
interested in improving APIeasy itself.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">_request</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="cm">/* method [uri, data, params] */</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</span>
<span class="nx">args</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span>
<span class="nx">method</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span>
Expand Down Expand Up @@ -326,7 +326,7 @@
<span class="p">}</span>
<span class="p">};</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-32"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-32">&#182;</a> </div> <p>A simple function that performs a deep clone on the specified <code>obj</code>.
We use this in RESTeasy to create multiple copies of the <code>options</code>
We use this in APIeasy to create multiple copies of the <code>options</code>
passed to <code>request</code> because they are considered mutable by <code>request</code>
and we strive to make each request idempotent. </p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">function</span> <span class="nx">clone</span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">copy</span> <span class="o">=</span> <span class="p">{};</span>
Expand Down
18 changes: 9 additions & 9 deletions lib/rest-easy.js → lib/api-easy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* rest-easy.js: Top-level include for the rest-easy module.
* api-easy.js: Top-level include for the api-easy module.
*
* (C) 2011, Charlie Robbins
*
Expand All @@ -16,10 +16,10 @@ var qs = require('querystring'),
exports.version = [0, 2, 0];

//
// ## RESTeasy.describe(text)
// This is the main (and sole) entry point for RESTeasy.
// ## APIeasy.describe(text)
// This is the main (and sole) entry point for APIeasy.
// It responds with an object literal that manages an
// underlying vows suite. Each call to `RESTeasy.describe()`
// underlying vows suite. Each call to `APIeasy.describe()`
// will create a vows suite, with the corresponding `text`
// passed to this method.
//
Expand Down Expand Up @@ -58,7 +58,7 @@ exports.describe = function (text) {
// Each call to discuss will create an object in the nested vows
// structure which has that text as the key in the parent. **e.g.:**
//
// RESTeasy.describe('your/awesome/api')
// APIeasy.describe('your/awesome/api')
// .use('localhost', 8080)
// .discuss('When using your awesome API')
// .discuss('and an awesome resource')
Expand Down Expand Up @@ -159,7 +159,7 @@ exports.describe = function (text) {
// ### Add HTTP Request-based Tests
// The `.get()`, `.post()`, `.put()`, `.del()`, and `.head()`
// methods add a new context and topic to the vows structure maintained
// by this RESTeasy suite. The nuts and bolts of this are in the "private"
// by this APIeasy suite. The nuts and bolts of this are in the "private"
// method `_request()`.
//
// Each method invocation returns the suite itself so that
Expand Down Expand Up @@ -280,7 +280,7 @@ exports.describe = function (text) {
// ### Run Your Tests
// Again, since we are managing a single vows suite in this object we
// should expose an easy way to export your tests to a given target without
// needing to call `restEasySuite.suite.export(module)`. You should only
// needing to call `apiEasySuite.suite.export(module)`. You should only
// call this method once in a given test file.
//
// You can also call `.run()` which will run the specified suite just
Expand Down Expand Up @@ -314,7 +314,7 @@ exports.describe = function (text) {
// `_request()` exists for the sake of DRY and simplicity and is designed to handle
// a variety of interal usage(s) exposed indirectly through the `.get()`,
// `.post()`, `.put()`, `.del()` and `.head()`. Nothing to see here unless you're
// interested in improving RESTeasy itself.
// interested in improving APIeasy itself.
//
_request: function (/* method [uri, data, params] */) {
var self = this,
Expand Down Expand Up @@ -412,7 +412,7 @@ exports.describe = function (text) {

//
// A simple function that performs a deep clone on the specified `obj`.
// We use this in RESTeasy to create multiple copies of the `options`
// We use this in APIeasy to create multiple copies of the `options`
// passed to `request` because they are considered mutable by `request`
// and we strive to make each request idempotent.
//
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "rest-easy",
"name": "api-easy",
"description": "Fluent (i.e. chainable) syntax for generating vows tests against RESTful APIs.",
"version": "0.2.0",
"author": "Charlie Robbins <[email protected]>",
"repository": {
"type": "git",
"url": "http://github.com/indexzero/rest-easy.git"
"url": "http://github.com/indexzero/api-easy.git"
},
"keywords": ["testing", "api", "REST", "vows"],
"dependencies": {
"journey": ">= 0.4.0-pre-2",
"request": ">= 1.9.0",
"vows": ">= 0.5.2"
},
"main": "./lib/rest-easy",
"main": "./lib/api-easy",
"scripts": { "test": "vows test/*-test.js --spec" },
"engines": { "node": ">= 0.4.3" }
}
14 changes: 7 additions & 7 deletions test/core-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* core-test.js: Tests for core functionality of RESTeasy.
* core-test.js: Tests for core functionality of APIeasy.
*
* (C) 2011, Charlie Robbins
*
Expand All @@ -10,17 +10,17 @@ require.paths.unshift(require('path').join(__dirname, '..', 'lib'));
var vows = require('vows'),
eyes = require('eyes'),
assert = require('assert'),
restEasy = require('rest-easy'),
apiEasy = require('api-easy'),
helpers = require('./helpers');

var scopes = ['When using the Test API', 'the Test Resource'];

vows.describe('rest-easy/core').addBatch({
"When using RESTeasy": {
topic: restEasy.describe('test/api').discuss('When using the Test API'),
vows.describe('api-easy/core').addBatch({
"When using APIeasy": {
topic: apiEasy.describe('test/api').discuss('When using the Test API'),
"it should have the correct methods set": function () {
assert.isFunction(restEasy.describe);
assert.length(Object.keys(restEasy), 2);
assert.isFunction(apiEasy.describe);
assert.length(Object.keys(apiEasy), 2);
},
"and a valid suite": {
"it should have the correct methods set": function (suite) {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* helpers.js: Test macros for RESTeasy.
* helpers.js: Test macros for APIeasy.
*
* (C) 2011, Charlie Robbins
*
Expand Down
10 changes: 5 additions & 5 deletions test/run-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* core-test.js: Tests for core functionality of RESTeasy.
* core-test.js: Tests for core functionality of APIeasy.
*
* (C) 2011, Charlie Robbins
*
Expand All @@ -10,18 +10,18 @@ require.paths.unshift(require('path').join(__dirname, '..', 'lib'));
var vows = require('vows'),
eyes = require('eyes'),
assert = require('assert'),
RESTeasy = require('rest-easy'),
APIeasy = require('api-easy'),
helpers = require('./helpers');

var scopes = ['When using the Test API', 'the Test Resource'];

vows.describe('rest-easy/run').addBatch({
"When using a RESTeasy suite": {
vows.describe('api-easy/run').addBatch({
"When using a APIeasy suite": {
"a suite of tests against a local test server": {
topic: function () {
helpers.startServer(8000);

var suite = RESTeasy.describe('api/test');
var suite = APIeasy.describe('api/test');

scopes.forEach(function (text) {
suite.discuss(text);
Expand Down

0 comments on commit 0c737a8

Please sign in to comment.