31 lines
1.0 KiB
CoffeeScript
31 lines
1.0 KiB
CoffeeScript
|
#expect = require("chai").expect
|
||
|
path = require("path")
|
||
|
|
||
|
Robot = require("hubot/src/robot")
|
||
|
TextMessage = require("hubot/src/message").TextMessage
|
||
|
|
||
|
before = (done) ->
|
||
|
robot = new Robot null, "mock-adapter", no, 'asjon'
|
||
|
robot.adapter.on 'connected', ->
|
||
|
#robot.loadFile (path.resolve path.join 'scripts/memoria.coffee'), 'memoria.coffee'
|
||
|
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 = []
|
||
|
# Mock http calls
|
||
|
###
|
||
|
robot.onHttp = (f) -> robot.httpListener = f
|
||
|
robot.http = (addr) ->
|
||
|
get: ->
|
||
|
robot.onHttp addr,
|
||
|
###
|
||
|
done
|
||
|
robot: robot, user: user, send: send, receive: receive
|
||
|
TextMessage: TextMessage, Robot: Robot
|
||
|
adapter: adapter, after: after, clear: clear
|
||
|
robot.run()
|
||
|
|
||
|
module.exports = before
|