travis-web/assets/scripts/spec/spec_helper.coffee
2013-03-06 14:43:13 +01:00

40 lines
1.2 KiB
CoffeeScript

minispade.require 'app'
@app = (url) ->
# TODO: this should wait till app is initialized, not some
# arbitrary amount of time
waits(50)
runs ->
Travis.reset()
url = "/#{url}" unless url.match /^\//
Travis.__container__.lookup('router:main').handleURL(url)
now = -> new Date('2012-07-02T00:03:00Z')
$.timeago.settings.nowFunction = -> now().getTime()
Travis.currentDate = now
# hacks for missing features in webkit
unless Function::bind
Function::bind = (oThis) ->
# closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable") if typeof this isnt "function"
aArgs = Array::slice.call(arguments, 1)
fToBind = this
fNOP = ->
fBound = ->
fToBind.apply (if this instanceof fNOP and oThis then this else oThis), aArgs.concat(Array::slice.call(arguments_))
fNOP.prototype = @.prototype
fBound.prototype = new fNOP()
fBound
window.history.state = {}
oldPushState = window.history.pushState
window.history.pushState = (state, title, href) ->
window.history.state = state
oldPushState.apply this, arguments