 define [
   'jquery'
+  'underscore'
   'chaplin/mediator'
   'chaplin/lib/router'
   'chaplin/controllers/controller'
   'chaplin/views/layout'
   'chaplin/views/view'
-], ($, mediator, Router, Controller, Layout, View) ->
+], ($, _, mediator, Router, Controller, Layout, View) ->
   'use strict'
 
   describe 'Layout', ->
     # Initialize shared variables
     layout = testController = startupControllerContext = router = null
+
+    createLink = (attributes) ->
+      attributes = if _.isObject(attributes) then _.clone(attributes) else {}
+      # Yes, this is ugly. We’re doing it because IE8-10 reports an incorrect
+      # protocol if the href attribute is set programatically.
+      if attributes.href?
+        div = document.createElement 'div'
+        div.innerHTML = "<a href='#{attributes.href}'>Hello World</a>"
+        link = div.firstChild
+        delete attributes.href
+        $link = $(link)
+      else
+        $link = $(document.createElement 'a')
+      $link.attr attributes
+
+    expectWasNotRouted = (linkAttributes) ->
+      spy = sinon.spy()
+      mediator.subscribe '!router:route', spy
+      $link = createLink linkAttributes
+      $link.appendTo(document.body).click().remove()
+      expect(spy).was.notCalled()
+      mediator.unsubscribe '!router:route', spy
 
     beforeEach ->
       # Create the layout

      spy = sinon.spy()
      mediator.subscribe '!router:route', spy
      path = '/an/internal/link'
      a = $('<a>').attr('href', path).text('Hello World')
        .appendTo(document.body)
        .click()
        .remove()
      expect(spy).was.called()
      args = spy.lastCall.args
      passedPath = args[0]


      # Create a fresh router
      router = new Router()

    afterEach ->
      layout.dispose()
