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

Test adapter #714

Closed
wants to merge 4 commits into from
Closed

Test adapter #714

wants to merge 4 commits into from

Conversation

atmos
Copy link
Contributor

@atmos atmos commented Jun 12, 2014

This is useful for testing standalone scripts. It has a simple array to capture responses availables as #history.

It looks like this in your tests.

Path  = require("path")
Robot = require("hubot").Robot

pkg = require Path.join __dirname, "..", 'package.json'
testAdapter = Path.join(__dirname, "adapters")

Version = pkg.version

describe "The Hubot Script", () ->
  robot = null
  beforeEach () ->
    robot = new Robot testAdapter, "test", false, "hubot"
    robot.loadFile  Path.join(__dirname, "..", "src"), "script.coffee"
    robot.run()

  afterEach () ->
    robot.shutdown()

  it "displays the version", () ->
    robot.adapter.receiveText("hubot deploy:version")
    expected = "hubot-deploy v#{Version}/hubot v2.7.5/node v0.10.21"
    assert.equal expected, robot.adapter.history

describe "The Hubot Script", () ->
robot = null
beforeEach () ->
robot = new Robot testAdapter, "test", false, "hubot"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is actually a lie. I don't know how to specify the path here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this only worked because hubot-deploy had this in a directory somewhere 😓

bin/hubot is the thing that actually determines this path: https://github.com/github/hubot/blob/master/bin/hubot#L73-L75

@technicalpickles
Copy link
Member

omg thank you 💖

Also worth noting that https://github.com/blalor/hubot-mock-adapter is a thing. Not sure how it differs yet.

it "displays the version", () ->
robot.adapter.receiveText("hubot deploy:version")
expected = "hubot-deploy v#{Version}/hubot v2.7.5/node v0.10.21"
assert.equal expected, robot.adapter.history
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robot.adapter.history is an array, right?

@technicalpickles
Copy link
Member

Hmm... I wonder if we could use this to support running a single hubot command. cc #613 @patcon

@atmos
Copy link
Contributor Author

atmos commented Jun 13, 2014

I found this and I'm digging it.

@atmos atmos closed this Jun 13, 2014
@atmos atmos deleted the test-adapter branch June 13, 2014 01:06
@technicalpickles
Copy link
Member

It doesn't actually depend on hubot, so maybe we can actually use that internally. But maybe that'd be weird?

@technicalpickles
Copy link
Member

Hwhoops, was reading dev dependencies, and it does depend on hubot. It'd still be nice to internal for testing still.

@atmos atmos restored the test-adapter branch June 13, 2014 01:19
@atmos
Copy link
Contributor Author

atmos commented Jun 13, 2014

Feel free to run with this. I'll let you guys decide. 😃

@atmos
Copy link
Contributor Author

atmos commented Jun 13, 2014

Maybe we pull in the changes in the repo I linked to? I'm using it and kinda like it.

@patcon
Copy link

patcon commented Sep 9, 2014

Heyo! So... is the consensus that hubot-test-helper is better than hubot-mock-adapter? Have used the latter, but not the former. Was going to add some tests to a repo, and then submit the change to generator-hubot-scripts if it seemed simpler.

@atmos
Copy link
Contributor Author

atmos commented Sep 9, 2014

I'm pretty happy with it, personally.

@patcon
Copy link

patcon commented Sep 10, 2014

Rockin. Don't suppose you've had a chance to test notifier scripts using the router? If you have and could point me to a reference, that'd be grand. But otherwise, I'll figure it out and doc it afterward

@bkeepers bkeepers deleted the test-adapter branch May 30, 2017 02:28
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

Successfully merging this pull request may close these issues.

3 participants