Permalink
Browse files

Handling global better in mocha's tests.

  • Loading branch information...
1 parent 0a78112 commit 37e170e575840aafc3446620db21c0e633074ebd @abernier committed May 3, 2012
View
@@ -9,19 +9,19 @@ describe "Ajax", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
require '../src/ajax'
$ = jQuery = Spine.$
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
User = undefined
jqXHR = undefined
View
@@ -8,17 +8,16 @@ describe 'Class', ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
-
- global.Spine ?= require '../src/spine'
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
User = undefined
@@ -9,18 +9,18 @@ describe "Controller", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
$ = jQuery = Spine.$
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
Users = undefined
element = undefined
View
@@ -9,18 +9,18 @@ describe "Events", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
$ = jQuery = Spine.$
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
EventTest = undefined
spy = undefined
View
@@ -9,19 +9,19 @@ describe "Manager", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
require '../src/manager'
$ = jQuery = Spine.$
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
Users = undefined
Groups = undefined
View
@@ -1,3 +1,3 @@
--compilers coffee:coffee-script
--reporter spec
---globals window,document,localStorage,Spine
+--globals window,document,localStorage,jQuery,Spine
View
@@ -9,18 +9,18 @@ describe "Model", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
$ = jQuery = Spine.$
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
Asset = undefined
@@ -9,20 +9,20 @@ describe "Model.Local", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
- global.localStorage ?= browser.localStorage('test')
+ global.document = browser.document
+ global.window = browser.window
+ global.localStorage = browser.localStorage('test')
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
require '../src/local'
$ = jQuery = Spine.$
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'localStorage', 'Spine']
+ delete global[key] for key in ['document', 'window', 'localStorage', 'jQuery', 'Spine']
User = undefined
@@ -9,19 +9,19 @@ describe "Model.Relation", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
require '../src/relation'
$ = jQuery = Spine.$
done()
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
Album = undefined
Photo = undefined
View
@@ -11,11 +11,11 @@ describe "Routing", ->
browser = new zombie.Browser()
browser.visit("file://localhost#{__dirname}/index.html", ->
- global.document ?= browser.document
- global.window ?= browser.window
- global.window.jQuery ?= require('jQuery').create(window)
+ global.document = browser.document
+ global.window = browser.window
+ global.jQuery = require('jQuery').create(window)
+ global.Spine = require '../src/spine'
- global.Spine ?= require '../src/spine'
require '../src/route'
Route = Spine.Route
$ = Spine.$
@@ -24,7 +24,7 @@ describe "Routing", ->
)
after ->
- delete global[key] for key in ['document', 'window', 'Spine']
+ delete global[key] for key in ['document', 'window', 'jQuery', 'Spine']
spy = undefined
clock = undefined
@@ -39,7 +39,7 @@ describe "Routing", ->
beforeEach ->
Route.setup()
-
+
noop = {spy: ->}
spy = sinon.spy(noop, "spy")

0 comments on commit 37e170e

Please sign in to comment.