0.1.3 • Published 9 years ago

mock-hubot-robot v0.1.3

Weekly downloads
10
License
ISC
Repository
github
Last release
9 years ago

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)
0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago