Skip to content

Commit

Permalink
prevent async fallthrough fails in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Eevert Saukkokoski committed Oct 23, 2014
1 parent e521a24 commit 125b68c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
8 changes: 4 additions & 4 deletions test/DefaultAjaxHeaderSpec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ describe "ag-restful.ajax", ->
app = null
server = null

beforeEach ->
beforeEach (done) ->
app = express()
server = app.listen(port)
server = app.listen port, done

afterEach ->
server.close()
afterEach (done) ->
server.close done

describe "when setting default headers for ajax requests", ->

Expand Down
35 changes: 18 additions & 17 deletions test/RestfulSpec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ restful = require '../src/ag/restful'

describe "ag-restful", ->
describe "Accessing data from a static REST backend", ->
port = 9876
TaskResource = null

port = 9001
app = null
server = null

beforeEach ->
beforeEach (done) ->
app = express()
app.use express.static "#{__dirname}/data"
server = app.listen(port)
server = app.listen port, done

afterEach ->
server.close()
afterEach (done) ->
server.close done

TaskResource = null

beforeEach ->
before ->
TaskResource = do ->
TaskType = types.Object
description: types.String
Expand All @@ -51,34 +51,35 @@ describe "ag-restful", ->

describe "A user-defined TaskResource", ->
it "can find all tasks", ->
TaskResource.findAll().should.eventually.be.an.array
TaskResource.findAll().then (tasks) ->
tasks.should.be.an.array

describe "a single task", ->
sampleTask = null

beforeEach ->
sampleTask = TaskResource.find('bltc95644acbfe2ca34')
TaskResource.find('bltc95644acbfe2ca34').then (task) ->
sampleTask = task

it "is an object", ->
sampleTask.should.eventually.be.an.object
sampleTask.should.be.an.object

it "has a description", ->
sampleTask.should.eventually.have.property('description').equal "take out the trash"

sampleTask.should.have.property('description').equal "take out the trash"

describe "Manipulating data in an express REST backend", ->
CatResource = null
port = 9876
app = null
server = null

beforeEach ->
beforeEach (done) ->
app = express()
app.use bodyparser.json()
server = app.listen(port)
server = app.listen port, done

afterEach ->
server.close()
afterEach (done) ->
server.close done

beforeEach ->
CatResource = do ->
Expand Down

0 comments on commit 125b68c

Please sign in to comment.