Skip to content

Instantly share code, notes, and snippets.

@kcrwfrd
Created June 21, 2015 21:35
Show Gist options
  • Save kcrwfrd/1b8cc32144fe926fa5ed to your computer and use it in GitHub Desktop.
Save kcrwfrd/1b8cc32144fe926fa5ed to your computer and use it in GitHub Desktop.
Fun little puzzle to apply to Rainforest QA
http = require 'http'
url = require 'url'
entry_url = 'http://letsrevolutionizetesting.com/challenge.json'
recurse = (url_string) ->
console.log '\nfollowing...', url_string
url_obj = url.parse url_string
return http.get
host: url_obj.host
port: 80
path: url_obj.path
headers:
'Accept': 'application/json'
, (response) ->
response.setEncoding 'utf8'
response.on 'data', (body) ->
body = JSON.parse body
if body.follow?
recurse body.follow
else
console.log "We've reached the bottom of the rabbit hole!", body
recurse entry_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment