Permalink
Browse files

Upgrade to Connect ~2.0.0

  • Loading branch information...
1 parent 1271b0f commit 4cf1e0ef3d6b1b7983d597172729a34568e33dab @grncdr grncdr committed Apr 6, 2012
View
1 lib/lazorse.coffee
@@ -22,7 +22,6 @@ module.exports = exports = (builder) ->
server.use connect.bodyParser()
server.use app
server.listen app.port
- server
###
The module also exports a function that constructs an app without starting a
View
4 package.json
@@ -20,7 +20,7 @@
},
"dependencies": {
"coffee-script": "~1.2.0",
- "connect": "~1.7.0",
+ "connect": "~2.0.0",
"uri-template": "~0.2.0"
},
"devDependencies": {
@@ -32,4 +32,4 @@
"prepublish": "coffee prepublish.coffee"
},
"optionalDependencies": {}
-}
+}
View
13 test/basics.test.coffee
@@ -1,9 +1,10 @@
+lazorse = require '../'
client = require('./client')
-server = require('connect').createServer()
assert = require 'assert'
# Test server
-server.use require('../lib/lazorse').app ->
+server = lazorse ->
+ @port = 0
for method in client.METHODS
resource = {}
uri = "/#{method}me"
@@ -30,12 +31,8 @@ server.use require('../lib/lazorse').app ->
# Tests
describe "A basic app", ->
- before (start) ->
- server.listen 0, 'localhost', ->
- client.usePort server.address().port
- start()
-
- after -> server.close()
+ before -> client.usePort server.address().port
+ after -> server.close()
it "has an index with three resources", (done) ->
client.GET '/', (res, resources) ->
View
6 test/before.test.coffee
@@ -3,15 +3,14 @@ Tests that the @before builder function inserts new middleware into the correct
position in the internal middleware stack
###
+lazorse = require '../'
client = require('./client')
-server = require('connect').createServer()
assert = require 'assert'
describe "An app with @before middleware", ->
stack = ['findResource', 'coerceParams', 'dispatchHandler', 'renderResponse']
- server = require('../lib/lazorse') ->
+ server = lazorse ->
@port = 0
-
response_data = word: 'up'
# Assert various attributes of the req/res state before each middleware
@@ -35,6 +34,7 @@ describe "An app with @before middleware", ->
next()
@resource '/ok': GET: -> @ok response_data
+
before -> client.usePort server.address().port
after -> server.close()
View
11 test/customErrors.test.coffee
@@ -1,5 +1,5 @@
+lazorse = require '../'
client = require('./client')
-server = require('connect').createServer()
assert = require('assert')
TeapotError = ->
@@ -12,7 +12,8 @@ CoffeepotError = ->
@message = "I'm a coffeepot"
Error.captureStackTrace @, TeapotError
-server.use require('../lib/lazorse').app ->
+server = lazorse ->
+ @port = 0
@resource '/byNameUnregistered':
GET: -> @error "TeapotError"
@@ -23,11 +24,7 @@ server.use require('../lib/lazorse').app ->
GET: -> @error TeapotError
describe "An app that uses custom errors", ->
- before (start) ->
- server.listen 0, 'localhost', ->
- client.usePort server.address().port
- start()
-
+ before -> client.usePort server.address().port
after -> server.close()
it "can't find errors by name when they aren't registered", (done) ->
View
11 test/examples.test.coffee
@@ -1,10 +1,11 @@
+lazorse = require '../'
client = require('./client')
-server = require('connect').createServer()
assert = require('assert')
errors = require '../lib/errors'
-server.use require('../lib/lazorse').app ->
+server = lazorse ->
+ @port = 0
@resource '/frob/{foozle}/{whatsit}':
GET: -> @error "teapot"
shortName: "frob"
@@ -24,11 +25,7 @@ server.use require('../lib/lazorse').app ->
describe "An app with examples", ->
- before (start) ->
- server.listen 0, 'localhost', ->
- client.usePort server.address().port
- start()
-
+ before -> client.usePort server.address().port
after -> server.close()
it 'has a link to /frob/examples in the index', (done) ->
View
3 test/named_middleware.test.coffee
@@ -1,8 +1,9 @@
+lazorse = require('../')
client = require('./client')
assert = require 'assert'
describe "Passing a string to @before", ->
- server = require('../lib/lazorse') ->
+ server = lazorse ->
@port = 0
@before @findResource, 'static', __dirname + '/static'
View
11 test/urlparams.test.coffee
@@ -1,5 +1,5 @@
client = require('./client')
-server = require('connect').createServer()
+lazorse = require '../'
assert = require('assert')
###
@@ -35,17 +35,14 @@ testResources =
# The handler to be used by all resources above
echo = -> @ok @req.vars
-server.use require('../lib/lazorse').app ->
+server = lazorse ->
+ @port = 0
resources = {}
resources[tpl] = {GET: echo} for tpl of testResources
@resource resources
describe "With URL parameters", ->
- before (start) ->
- server.listen 0, 'localhost', ->
- client.usePort server.address().port
- start()
-
+ before -> client.usePort server.address().port
after -> server.close()
for _, exp of testResources

0 comments on commit 4cf1e0e

Please sign in to comment.