Skip to content

Commit

Permalink
Tweak test case to fail better
Browse files Browse the repository at this point in the history
Test cases should fail fast and loud instead of by hitting a timeout
  • Loading branch information
michaelansel committed Aug 26, 2015
1 parent 980b2d8 commit b58e8d1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/robot_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -748,19 +748,22 @@ describe 'Robot', ->
execution = []

testMiddlewareA = (context, next, done) ->
context.response.message.text = "foobar"
context.response.message.text = 'foobar'
next()

testMiddlewareB = (context, next, done) ->
# Subsequent middleware should see the modified message
expect(context.response.message.text).to.equal("foobar")
next()

@robot.receiveMiddleware testMiddlewareA
@robot.receiveMiddleware testMiddlewareB

@robot.hear /^foobar$/, () ->
# We'll never get to this if testMiddlewareA has not modified the message.
testDone()
testCallback = sinon.spy()
# We'll never get to this if testMiddlewareA has not modified the message.
@robot.hear /^foobar$/, testCallback

testMessage = new TextMessage @user, 'message123'
@robot.receive testMessage
@robot.receive testMessage, ->
expect(testCallback).to.have.been.called
testDone()

0 comments on commit b58e8d1

Please sign in to comment.