Skip to content

Instantly share code, notes, and snippets.

@PandaWhisperer
Created January 28, 2015 00:53
Show Gist options
  • Save PandaWhisperer/cb939045fc5e84bf9533 to your computer and use it in GitHub Desktop.
Save PandaWhisperer/cb939045fc5e84bf9533 to your computer and use it in GitHub Desktop.
{discover} = require "pbx/client"
amen = require "amen"
assert = require "assert"
amen.describe "One-time message pad", (context) ->
context.test "Create a message", (context) ->
api = yield discover "http://localhost:8080"
{response: {headers: {location}}} =
(yield api.messages.create content: "Test Message")
message = (api.message location)
context.test "Retrieve a message", ->
{data} = yield message.get()
{content} = yield data
assert.equal content, "Test Message"
context.test "Retrieving a message deletes it", ->
try
yield message.get()
catch e
assert e.message.match /404/
return true
assert false, "Expected Error, but none was thrown"
@dyoder
Copy link

dyoder commented Jan 28, 2015

So you couldn't do:

assert.throws -> (yield message.get())

?

@PandaWhisperer
Copy link
Author

Nope. I'm getting

 AssertionError: Missing expected exception.

@dyoder
Copy link

dyoder commented Jan 28, 2015

I just ran this and it worked fine:

assert.throws -> throw "foo"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment