25 lines
831 B
CoffeeScript
25 lines
831 B
CoffeeScript
path = require "path"
|
|
|
|
Robot = require("hubot/src/robot")
|
|
TextMessage = require("hubot/src/message").TextMessage
|
|
|
|
before = (done) ->
|
|
process.env.TESTING_ASJON = 'true'
|
|
robot = new Robot null, "mock-adapter", no, 'asjon'
|
|
robot.adapter.on 'connected', ->
|
|
# Initialize mocked environment
|
|
user = robot.brain.userForId "1", { name: 'mocha', room: '#mocha' }
|
|
adapter = robot.adapter
|
|
send = (s) -> robot.adapter.receive new TextMessage user, s
|
|
receive = (f) -> robot.adapter.on 'send', f
|
|
after = -> robot.shutdown()
|
|
clear = -> robot.adapter.removeAllListeners(); robot.httpListener = ->
|
|
# Done
|
|
done
|
|
robot: robot, user: user, send: send, receive: receive
|
|
TextMessage: TextMessage, Robot: Robot
|
|
adapter: adapter, after: after, clear: clear
|
|
robot.run()
|
|
|
|
module.exports = before
|