Created
October 20, 2011 00:48
-
-
Save dyoder/1300121 to your computer and use it in GitHub Desktop.
Test For Stubby API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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