Skip to content

Instantly share code, notes, and snippets.

@dyoder
Created October 20, 2011 00:48
Show Gist options
  • Save dyoder/1300121 to your computer and use it in GitHub Desktop.
Save dyoder/1300121 to your computer and use it in GitHub Desktop.
Test For Stubby API
s = this; s.API.discovery "http://localhost:1337/", (description) ->
s.Account.create description, (account) ->
channel_name = "Foo"; message = "Hello, World!"
s.Session.create [description, account], (session) ->
s.Channel.create [description,session.channels,channel_name],
(channel) ->
s.Channel.publish [description,channel,message]
# Okay, now create another session and get the message
s.Session.create [description, account], (session) ->
channels = [session.channels.resources[channel_name]]
s.Subscription.create [description,session,channels,"messages"],
(subscription) ->
s.Subscription.listen [description,subscription],
(events,specification) ->
console.log(events)
specification.assert "includes the message we published", ->
assert.equal events.messages[0].content,message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment