2015-04-28 15:41:57 +02:00
|
|
|
path = require "path"
|
2015-04-27 16:40:35 +02:00
|
|
|
|
|
|
|
Robot = require("hubot/src/robot")
|
|
|
|
TextMessage = require("hubot/src/message").TextMessage
|
|
|
|
|
2015-09-26 18:14:55 +02:00
|
|
|
# Raise listeners limit
|
|
|
|
process.setMaxListeners(20)
|
|
|
|
|
2015-04-27 16:40:35 +02:00
|
|
|
before = (done) ->
|
2015-04-28 14:07:22 +02:00
|
|
|
process.env.TESTING_ASJON = 'true'
|
2015-04-27 16:40:35 +02:00
|
|
|
robot = new Robot null, "mock-adapter", no, 'asjon'
|
|
|
|
robot.adapter.on 'connected', ->
|
2015-04-27 21:34:03 +02:00
|
|
|
# Initialize mocked environment
|
2017-02-22 22:11:20 +01:00
|
|
|
user = robot.brain.userForId "1", { name: 'mocha', room: name: 'mocha', id: '#mocha' }
|
2015-04-27 16:40:35 +02:00
|
|
|
adapter = robot.adapter
|
|
|
|
send = (s) -> robot.adapter.receive new TextMessage user, s
|
|
|
|
receive = (f) -> robot.adapter.on 'send', f
|
|
|
|
after = -> robot.shutdown()
|
2015-04-27 21:34:03 +02:00
|
|
|
clear = -> robot.adapter.removeAllListeners(); robot.httpListener = ->
|
|
|
|
# Done
|
2015-04-27 16:40:35 +02:00
|
|
|
done
|
|
|
|
robot: robot, user: user, send: send, receive: receive
|
|
|
|
TextMessage: TextMessage, Robot: Robot
|
|
|
|
adapter: adapter, after: after, clear: clear
|
|
|
|
robot.run()
|
|
|
|
|
|
|
|
module.exports = before
|