Browse files

Merge branch 'return-handler'

  • Loading branch information...
2 parents f9ccf71 + d74f967 commit 1292da20fe90f326eca85e0c49196de59889bcb9 @dan-manges committed Jul 3, 2011
Showing with 31 additions and 1 deletion.
  1. +4 −0 README.md
  2. +2 −0 Rakefile
  3. +2 −1 lib/m2node.js
  4. +2 −0 package.json
  5. +20 −0 spec/m2node_spec.js
  6. +1 −0 src/m2node.coffee
View
4 README.md
@@ -52,4 +52,8 @@ m2node.run(app, {
});
```
+contributors
+------------
+
+see package.json
View
2 Rakefile
@@ -15,6 +15,7 @@ end
namespace :test do
namespace :app do
+ desc "start test app"
task :start => :compile do
sh "coffee spec/app.coffee"
end
@@ -27,6 +28,7 @@ namespace :test do
end
end
+ desc "start mongrel2 for tests"
task :start => :load do
Dir.chdir(SPEC_DIR) do
sh "m2sh start -name m2node_tests --db config.sqlite"
View
3 lib/m2node.js
@@ -6,7 +6,7 @@
exports.run = function(server, options) {
var handler;
handler = new Handler(options);
- return handler.on('request', function(request) {
+ handler.on('request', function(request) {
var fakeSocket;
fakeSocket = new FakeSocket();
fakeSocket.on('write', function() {
@@ -15,5 +15,6 @@
server.emit('connection', fakeSocket);
return fakeSocket.emitData(request.toFullHttpRequest());
});
+ return handler;
};
}).call(this);
View
2 package.json
@@ -5,6 +5,8 @@
"keywords" : ["http", "mongrel2"],
"homepage" : "https://github.com/dan-manges/m2node",
"author" : "Dan Manges <dan.manges@gmail.com> (http://www.dan-manges.com)",
+ "contributors" :
+ [ "Paul Bergeron <paul.d.bergeron@gmail.com>" ],
"main" : "./lib/m2node.js",
"repository" : { "type": "git", "url" : "https://github.com/dan-manges/m2node.git" },
"engines" : { "node": "~0.4.8" },
View
20 spec/m2node_spec.js
@@ -1,6 +1,8 @@
var vows = require('vows');
var assert = require('assert');
var http = require('http');
+var m2node = require('../lib/m2node');
+var sys = require('sys');
vows.describe('m2node').addBatch({
'smoke test': {
@@ -148,5 +150,23 @@ vows.describe('m2node').addBatch({
assert.equal(response.body.toString(), '/echo_request_url?a=b&c=d');
}
},
+
+ 'return value from m2node.run': {
+ topic: function () {
+ server = http.createServer(function (req, res) {
+ });
+ handler = m2node.run(server, {
+ send_spec: 'tcp://127.0.0.1:9991',
+ recv_spec: 'tcp://127.0.0.1:9992'
+ });
+ this.callback(null, handler);
+ },
+ 'returns the handler with access to sockets': function (err, handler) {
+ assert.isObject(handler.pullSocket);
+ assert.isObject(handler.pubSocket);
+ handler.pullSocket.close();
+ handler.pubSocket.close();
+ }
+ }
}).export(module)
View
1 src/m2node.coffee
@@ -11,4 +11,5 @@ exports.run = (server, options) ->
handler.sendResponse(request, fakeSocket.writeBuffer)
server.emit 'connection', fakeSocket
fakeSocket.emitData(request.toFullHttpRequest())
+ handler

0 comments on commit 1292da2

Please sign in to comment.