Permalink
Browse files

nock example for the att put test

  • Loading branch information...
1 parent 005febe commit af61d39d4085063a06936ee35bd474f088da687d @pgte pgte committed Nov 30, 2011
Showing with 32 additions and 7 deletions.
  1. +2 −2 package.json
  2. +30 −5 tests/att/destroy.js
View
@@ -4,15 +4,15 @@
, "repository" : "git://github.com/dscape/nano"
, "version" : "0.9.5"
, "author" : "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"
-, "contributors" :
+, "contributors" :
[ "Thiago Arrais <thiago.arrais@gmail.com> (http://thiagoarrais.com)"
, "Derek Perez <derek@derekperez.com> (http://blog.derekperez.com)"
, "Patrick Heneise (http://patrickheneise.me)"
, "Artur Konarski (http://tarantoga.com)"
]
, "keywords" : ["couchdb", "data", "request", "json", "nosql", "micro", "nano"]
, "dependencies" : {"request": "2.2.0", "underscore": "~1.1.7"}
-, "devDependencies" : { "async": "~0.1.9", "ensure": "0.4.6", "nock": "0.3.1"}
+, "devDependencies" : { "async": "~0.1.9", "ensure": "0.4.6", "nock": "0.4.x"}
, "scripts" : { "test": "./node_modules/ensure/bin/tap.js tests/*/*.js" }
, "main" : "./nano.js"
, "engines" : { "node": ">=0.3.6" }
View
@@ -4,18 +4,43 @@ var ensure = require('ensure')
, db_name = require('../utils').db_name("att_de")
, tests = exports
, nock = require('nock')
- , couchdb = nock(cfg.url)
- .put( '/' + db_name("a")
+ , path
+ , location
+ , couchdb
+ ;
+
+ path = '/' + db_name("a");
+ location = cfg.url + path;
+ couchdb = nock(cfg.url)
+ .put(path
, ''
, { 'content-type': 'application/json'
, "accept": 'application/json' })
.reply(201, { ok: true },
- { location: 'http://nodejsbug.iriscouch.com/v061_att_dea'
+ { location: location
+ , date: 'Wed, 30 Nov 2011 15:21:58 GMT'
+ , 'content-type': 'application/json'
+ , 'cache-control': 'must-revalidate'
+ , 'status-code': 201
+ })
+
+ .put(path + '/new/att', "\"Hello World!\"")
+ .reply(201, { ok: true, id: 'new', rev: '1-921bd51ccdef5ab4c84b07bab7b80e7e' },
+ { location: location + '/new/att'
, date: 'Wed, 30 Nov 2011 15:21:58 GMT'
, 'content-type': 'application/json'
, 'cache-control': 'must-revalidate'
, 'status-code': 201
})
+
+ .delete(path + '/new/att?rev=1-921bd51ccdef5ab4c84b07bab7b80e7e')
+ .reply(201, { ok: true, id:'new' },
+ { location: location + '/new/att?rev=1-921bd51ccdef5ab4c84b07bab7b80e7e'
+ , date: 'Wed, 30 Nov 2011 15:21:58 GMT'
+ , 'content-type': 'application/json'
+ , 'cache-control': 'must-revalidate'
+ , 'status-code': 201
+ })
;
function db(i) { return nano.use(db_name(i)); }
@@ -30,11 +55,11 @@ tests.att_des = function (callback) {
};
tests.att_des_ok = function (e,b) {
- nano.db.destroy(db_name("a"));
+ //nano.db.destroy(db_name("a"));
this.t.notOk(e);
this.t.ok(b.ok);
this.t.equal(b.id, "new");
- couchdb.done();
+ this.t.ok(couchdb.isDone());
};
ensure(__filename,tests,module,process.argv[2]);

0 comments on commit af61d39

Please sign in to comment.