Skip to content
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

Allow user to require the Hubot script themselves #46

Open
strugee opened this issue Aug 25, 2017 · 3 comments
Open

Allow user to require the Hubot script themselves #46

strugee opened this issue Aug 25, 2017 · 3 comments

Comments

@strugee
Copy link

strugee commented Aug 25, 2017

I have a script which is using res.random. Obviously that's hard to test for, so I want to use proxyquire to override the require that gets the possible responses, such that there's only one possible response. However I can't do this because hubot-test-helper is calling require() for me.

It'd be nice if I could just pass in a function and have that interpreted by hubot-test-helper as the plugin itself, pre-require()'d.

@alFReD-NSH
Copy link
Contributor

You can do something like this:

Helper = require('hubot-test-helper')
helper = new Helper sctiptPath
room = helper.createRoom name: 'bob'
room.robot.Response = class extends Helper.Response
  # Generated using a fair dice!
  random: -> 4

strugee added a commit to strugee/hubot-botsnack that referenced this issue Sep 29, 2017
@strugee
Copy link
Author

strugee commented Sep 29, 2017

Thank you! That worked perfectly 👍

Maybe that should be documented somewhere? Unless I just missed it...

@alFReD-NSH
Copy link
Contributor

No, its not documented. Feel free to open a pull request to update the readme to have this trick :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants