   helpers.render source, context, (node, view) ->
     delay ->
       ok spy.callCount, 5
-      context.children.add 'f'
+      view.children.add 'f'
       delay ->
         ok spy.callCount, 6
 


asyncTest 'it should allow loops over undefined values', 3, ->
  source = '<p data-foreach-object="objects" class="present" data-bind="object"></p>'
  context = Batman()
  Batman.developer.suppress()
  helpers.render source, context, (node, view) ->
    deepEqual getPs(view), []
    context.set 'objects', new Batman.Set('foo', 'bar', 'baz')
    delay ->
      deepEqual getPs(view), ['foo', 'bar', 'baz']
      context.unset 'objects'
      delay ->
        deepEqual getPs(view), []
        Batman.developer.unsuppress()

helpers = if typeof require is 'undefined' then window.viewHelpers else require './view_helper'
getPs = (view) -> $('p', view.get('node')).map(-> @innerHTML).toArray()

QUnit.module "Batman.View loop rendering"

asyncTest 'it should allow simple loops', 1, ->
  source = '<p data-foreach-object="objects" class="present" data-bind="object"></p>'
  objects = new Batman.Set('foo', 'bar', 'baz')
