icinga-hubot-script
Version:
A hubot script that takes notification messages from Icinga and post them to any IRC channel
41 lines (32 loc) • 1.29 kB
text/coffeescript
chai = require 'chai'
sinon = require 'sinon'
chai.use require 'sinon-chai'
expect = chai.expect
describe 'icinga-hubot', ->
beforeEach ->
=
respond: sinon.spy()
hear: sinon.spy()
router:
post: sinon.spy()
require('../src/icinga-hubot')()
it 'listens to post requests on path "/hubot/icinga-hubot/notify"', ->
expect(.router.post).to.have.been.calledWith('/hubot/icinga-hubot/notify', sinon.match.any)
describe 'on post request', ->
beforeEach ->
=
body:
ICINGA_CONTACTADDRESS0: 'any_contact_address'
=
end: sinon.spy()
.send = sinon.spy()
.router.post.lastCall.args[1](, )
it 'sets status code 201 on response', ->
expect(.statusCode).to.equal(201)
it 'calls "end" on response', ->
expect(.end).to.have.been.calledOnce
it 'sets "envelope.room" using "ICINGA_CONTACTADDRESS0" from post', ->
expectedEnvelope = room : 'any_contact_address'
expect(.send).to.have.been.calledWith(expectedEnvelope, sinon.match.any)
it 'sends the messages created by message creator', ->
expect(.send).to.have.been.calledWith(sinon.match.any, sinon.match.any)