The following test will pass if I run each spec independently. If I run them in succession only the first spec will pass.
#= require spec_helper
#= require models/job
#= require ./fixtures/job
describe "Job", ->
beforeEach (done) ->
@job = App.Job.find(1)
@job.on 'didLoad', -> done()
it "returns property idName", ->
expect( @job.get('idName') ).to.equal("#1 - first job")
it "expects property idName to update if name changes", ->
@job.set('name', 'new name')
expect( @job.get('idName') ).to.equal("#1 - new name")
it "expects property idName to update if originalId changes", ->
@job.set('originalId', 7)
expect( @job.get('idName') ).to.equal("#7 - first job")
The error konacha is giving me is:
Error: timeout of 2000ms exceeded at http://localhost:3500/assets/mocha.js:4001:14
Anyone have any suggestions. Should I use jasmine?
Okay I have a solution. I was thinking the app was initialized before each spec. It seems after the first test the job is loaded so I am checking if the job is loaded and calling the done function.
beforeEach (done) ->
@job = App.Job.find(1)
@job.on 'didLoad', -> done()
afterEach ->
Ember.run ->
App.reset()