Permalink
Browse files

fixes #6 - patchboard client crash

  • Loading branch information...
automatthew committed Sep 14, 2012
1 parent 314c649 commit be137fd95d7e2195be3efc7c7c040714d15bb347
Showing with 20 additions and 9 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 Rakefile
  3. +1 −1 package.json
  4. +2 −1 src/client.coffee
  5. +14 −7 src/testify.coffee
View
@@ -1,2 +1,3 @@
mine
node_modules
.starter
View
@@ -1,3 +1,5 @@
require "starter/tasks/github"
$COFFEE = File.expand_path("node_modules/.bin/coffee")
$BROWSERIFY = File.expand_path("node_modules/.bin/browserify")
View
@@ -2,7 +2,7 @@
"name": "patchboard",
"description": "Self-assembling HTTP APIs",
"author": "Matthew King",
"version": "0.2.2",
"version": "0.2.3",
"repository": {
"type": "git",
"url": "https://github.com/automatthew/patchboard/"
View
@@ -233,6 +233,7 @@ class Client
if request_type = definition.request_schema
request_media_type = client.schema_manager.find(request_type).mediaType
default_headers["Content-Type"] = request_media_type
# FIXME: we should also check for definition.accept
if response_type = definition.response_schema
response_schema = client.schema_manager.find(response_type)
response_media_type = response_schema.mediaType
@@ -253,7 +254,7 @@ class Client
# verify presence of the required query params from the schema
for key, value of required_params
if !request.query[key]
if !request.query || !request.query[key]
throw "Missing required query param: #{key}"
if authorization
View
@@ -15,16 +15,29 @@ testify = (name, fn) ->
success(name)
else
context = create_context(name)
context.emitter.on "done", () -> success(name)
testify.count++
context.emitter.on "done", ->
success(name)
testify.count--
if testify.count == 0
testify.emitter.emit("done")
fn(context)
catch error
failure(name, error)
process.exit()
testify.count = 0
testify.later = (name, fn) ->
() ->
testify(name, fn)
testify.emitter = new EventEmitter()
testify.on = (args...) ->
testify.emitter.on(args...)
success = (name) -> console.log colors.green("Pass: '#{name}'")
failure = (name, error) ->
@@ -60,12 +73,6 @@ create_context = (name) ->
name: name
emitter: emitter
done: () -> emitter.emit("done")
wrap: (callback) ->
(args...) ->
try
callback(args...)
catch error
failure(name, error)
assert: assertions(name)
#assert.partialEqual = (actual, expected) ->

0 comments on commit be137fd

Please sign in to comment.