mtsmfm / hubot-test-helper

Helper for testing hubot script
MIT License
115 stars 40 forks source link

test sendPrivate to specific user #38

Open sbounmy opened 8 years ago

sbounmy commented 8 years ago

Hey,

Is there a way to test when bot initiate a private message ? ex:

//script
module.exports = (robot) ->
  robot.hear /onboard (@.*)/, (res) ->
    name = res.match[1]
    res.send "Glad to see a new face! Onboarding #{name} right now"
    res.sendPrivate name, "hey #{name} can you tell me your secret password ?"
//test
  it 'initiate a private message to user', ->
    @room.user.say('stephane', 'onboard @arthur 28/10').then =>
      expect(@room.privateMessages).to.eql {
        'arthur': [
          ['hubot', 'hey @arthur can you tell me your secret password ?']
        ]
      }
faridnsh commented 7 years ago

You can do this using robot.sendPrivate. Should exactly do what you want.