Skip to content

Provides a mock robot context used to provide testing support for Hubot script development

Notifications You must be signed in to change notification settings

gettyimages/mock-hubot-robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mock-hubot-robot

Provides a mock robot context used to provide testing support for Hubot script development

Install

npm install mock-hubot-robot

Features

Currently only supports testing regex triggers

Use

Assuming a file in a test folder off the root of your hubot source Using Mocha and Chai

some-test-file-name.js

require('coffee-script')
require('coffee-script/register')
var robotCtx = require('../')(),
    testscript = require('./testscript.coffee'),
    expect = require('chai').expect

describe('Testing that my robot hears correctly',function() {
  before(function(done) {
    //This is what binds the robot context into your script.
    testscript(robotCtx)
    done()
  })
  
  it('hears phrase "who\'s here"',function(done) {
    //Execute your phrase against all of the robot.hear bindings your script has made
    robotCtx.ExecHear("who's here?",function(matched) {
      expect(matched).to.be.true
      done()
    })
  })
})

testscript.coffee

module.exports = (robot) ->
  robot.hear /who's here/, (res) ->
    console.log("called")

Output

  Testing that my robot hears correctly
    ✓ hears phrase "who's here"


  1 passing (11ms)

About

Provides a mock robot context used to provide testing support for Hubot script development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published