Files
habitica/test/test2/lib/helpers.coffee
T
2013-03-22 13:40:38 -06:00

36 lines
1.3 KiB
CoffeeScript

utils = require('utils')
module.exports = ->
baseUrl = 'http://localhost:3000'
casper = require("casper").create
clientScripts: 'lib/lodash.min.js'
getModel = (cb)->
casper.echo 'Loading model...'
casper.waitFor(
-> #check function
casper.evaluate ->
user = window.DERBY.app.model.get('_user')
#wait till all fields get ready
check = (typeof user == "object" && typeof user.stats == "object" && typeof user.stats.exp == 'number')
#assign to the window so we can access it later
window.userCopy = userCopy = {}
#dirty hack to get all fields in the object
for k of user
userCopy[k] = user[k]
check
-> #run this if check passed
model = casper.evaluate ->
{user: window.userCopy}
casper.echo '...model loaded'
utils.dump model.user.stats
cb model
)
{
casper: casper
baseUrl: baseUrl
playUrl: baseUrl + '/?play=1'
utils: utils
getModel: getModel
}