-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nothing stored in brain #31
Comments
It's important to consider the test script as a new version of your Hubot, everytime it's run. It doesn't use your existing Hubot or existing Brain, it's all fake and local to the test script only. So as part of your 'beforeEach' you also have to tell it what should be in the brain when you run it, if something is required. i.e, with my PING command I require you to be an Admin. Thus, I need to load my auth.coffee, as it's part of the ping.coffee script. I also need to have an environmental variable for the auth.coffee file to know who is the Admin, and it also needs to check the brain for the user who is talking, get their ID, and check it against the admin list:
|
Hi, Thank you! Cheers, Yan Georget On Fri, Sep 2, 2016 at 5:34 PM, Patrick B [email protected] wrote:
|
Hello,
I'd like to test the content of the brain but nothing seems to be stored in it when I run my tests.
packages.json:
{
"name": "...",
"version": "0.1.0",
"private": true,
"author": "...,
"description": "...",
"scripts": {
"test": "mocha --compilers coffee:coffee-script/register tests"
},
"dependencies": {
"hubot": "latest",
"hubot-brain-inspect": "latest",
"hubot-redis-brain": "latest",
"log4js": "latest",
"natural": "latest"
},
"devDependencies": {
"bluebird": "latest",
"chai": "latest",
"coffee-script": "^1.9.3",
"coffeelint": "latest",
"hubot-test-helper": "latest",
"mocha": "latest"
},
"engines": {
"node": "6.1.0"
}
}
test.coffee:
Helper = require('hubot-test-helper')
helper = new Helper('./../scripts')
Promise = require('bluebird')
co = require('co')
expect = require('chai').expect
describe 'hello-world', ->
beforeEach ->
@room = helper.createRoom()
afterEach ->
@room.destroy()
context 'user says hi to hubot', ->
beforeEach ->
co =>
yield @room.user.say('alice', '@...bot hi')
yield @room.user.say('alice', '@...bot trip')
STDOUT:
...
[2016-05-16 22:05:15.249] [DEBUG] Message - log_user: brain {"users":{},"_private":{}}
...
The text was updated successfully, but these errors were encountered: