diff --git a/README.md b/README.md index f6dbf98..341489d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# RESTeasy +# APIeasy A fluent (i.e. chainable) syntax for generating vows tests against RESTful APIs. @@ -9,18 +9,18 @@ A fluent (i.e. chainable) syntax for generating vows tests against RESTful APIs. curl http://npmjs.org/install.sh | sh -### Installing RESTeasy +### Installing APIeasy
- [sudo] npm install rest-easy + [sudo] npm install api-easy## 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:
Suite → Batch* @@ -28,13 +28,13 @@ If you're going to use RESTeasy (and I hope you do), it's worth taking a moment Context → Topic? Vow* Context*-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:
var request = require('request'), @@ -71,13 +71,13 @@ Here's a sample of the boilerplate code that RESTeasy eliminates: }).export(module);-This same code can be implemented like this using RESTeasy: +This same code can be implemented like this using APIeasy:
- 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') @@ -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 diff --git a/docs/rest-easy.html b/docs/api-easy.html similarity index 97% rename from docs/rest-easy.html rename to docs/api-easy.html index 9556874..3b1bc97 100644 --- a/docs/rest-easy.html +++ b/docs/api-easy.html @@ -1,5 +1,5 @@ -rest-easy.js
rest-easy.js
/* - * rest-easy.js: Top-level include for the rest-easy module. +api-easy.js
api-easy.js
/* + * api-easy.js: Top-level include for the api-easy module. * * (C) 2011, Charlie Robbins * @@ -8,11 +8,11 @@ var qs = require('querystring'), request = require('request'), vows = require('vows'), - assert = require('assert');Version 0.2.0 // 03/22/2011
exports.version = [0, 2, 0];RESTeasy.describe(text)
+ assert = require('assert');Version 0.2.0 // 03/22/2011
exports.version = [0, 2, 0];APIeasy.describe(text)
-This is the main (and sole) entry point for RESTeasy. +
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 toAPIeasy.describe()
will create a vows suite, with the correspondingtext
passed to this method. exports.describe = function (text) { return {State / Context management:
@@ -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. 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') @@ -127,7 +127,7 @@
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 @@ -231,7 +231,7 @@
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 callapiEasySuite.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 @@ -262,7 +262,7 @@
_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. _request: function (/* method [uri, data, params] */) { +interested in improving APIeasy itself. _request: function (/* method [uri, data, params] */) { var self = this, args = Array.prototype.slice.call(arguments), method = args.shift(), @@ -326,7 +326,7 @@ } }; };A simple function that performs a deep clone on the specified
obj
. -We use this in RESTeasy to create multiple copies of theoptions
+We use this in APIeasy to create multiple copies of theoptions
passed torequest
because they are considered mutable byrequest
and we strive to make each request idempotent. function clone (obj) { var copy = {}; diff --git a/lib/rest-easy.js b/lib/api-easy.js similarity index 96% rename from lib/rest-easy.js rename to lib/api-easy.js index 154481e..5d4ca03 100644 --- a/lib/rest-easy.js +++ b/lib/api-easy.js @@ -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 * @@ -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. // @@ -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') @@ -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 @@ -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 @@ -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, @@ -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. // diff --git a/package.json b/package.json index c81e312..41169a3 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "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", "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": { @@ -13,7 +13,7 @@ "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" } } diff --git a/test/core-test.js b/test/core-test.js index dbe8816..07e8968 100644 --- a/test/core-test.js +++ b/test/core-test.js @@ -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 * @@ -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) { diff --git a/test/helpers.js b/test/helpers.js index 65a9bd6..744df78 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -1,5 +1,5 @@ /* - * helpers.js: Test macros for RESTeasy. + * helpers.js: Test macros for APIeasy. * * (C) 2011, Charlie Robbins * diff --git a/test/run-test.js b/test/run-test.js index ccf29b5..836765e 100644 --- a/test/run-test.js +++ b/test/run-test.js @@ -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 * @@ -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);