Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created December 19, 2010 19:05
Show Gist options
  • Save indexzero/747592 to your computer and use it in GitHub Desktop.
Save indexzero/747592 to your computer and use it in GitHub Desktop.
{
'We make sure we can talk to Twitter':
/* We'll be using same server for following requests. */
using('api.twitter.com')
.get('/help/test.json')
.expect(200, "ok", "/help/test.json returns 200 and ok")
.get('/help/test.txt')
/* Here we ignore response */
.expect(406, dc.ignore(), "/help/test.txt is not acceptable"),
'We need to know what are the hot trends in the twittersphere':
using('api.twitter.com')
.get('/trends.json')
/* We want to make sure a structure is returned ... */
.expect(200, {
/* ... it has as_of key whose value matches regexp. */
as_of: dc.RegEx(/\w+, \d+ \w+ \d+ \d+:\d+:\d+ \+\d+/),
/* ... and has array with at least one structure
* with keys name and url whose values are not so
* important
*/
trends: [ { name: dc.ignore(), url: dc.ignore() } ]
}, "/trends.json return 200 and reasonable answer",
/* We can store the result and response for later */
['trend_rc', 'trend_resp'])
/* And here we can refrence what we've stored in previous step */
.get('http://search.twitter.com/search.json?q=<%=trend_resp.trends[0].name%>')
.expect(200, {
/* Some keys are important for us. */
results: [],
query: dc.ignore(),
max_id: dc.ignore()
}, "We make sure we got what we were looking for.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment