spec/javascripts/helpers/spec_helper.js.coffee in joosy-0.1.0.alpha vs spec/javascripts/helpers/spec_helper.js.coffee in joosy-1.0.0.RC1
- old
+ new
@@ -1,8 +1,13 @@
beforeEach ->
+ Joosy.Resource.Generic.resetIdentity()
+
+ window.JST = {}
$('body').append('<div id="ground">')
+
@ground = $('body #ground')
+
@seedGround = ->
@ground.html('
<div id="application" class="application">
<div id="header" class="header" />
<div id="wrapper" class="wrapper">
@@ -17,8 +22,28 @@
</div>
</div>
<div id="footer" class="footer" />
</div>
')
+
+ @addMatchers
+ toBeSequenced: () ->
+ if !Object.isArray(@actual) || @actual.length == 0
+ console.log 'toBeSequenced: not array or empty array given'
+ return false
+ i = 0
+ for spy in @actual
+ unless spy.callCount == 1
+ console.log "toBeSequenced: spy ##{i} was called #{spy.callCount} times"
+ return false
+ i++
+ if @actual.length > 1
+ for spy in @actual.from(1)
+ i = @actual.indexOf spy
+ previous = @actual[i - 1]
+ unless spy.calledAfter previous
+ console.log "toBeSequenced: spy ##{i} wasn't called after spy ##{i - 1}"
+ return false
+ return true
afterEach ->
@ground.remove() unless @polluteGround
\ No newline at end of file