Skip to content

needed more business cat#10

Open
dguido wants to merge 4 commits intollimllib:masterfrom
dguido:master
Open

needed more business cat#10
dguido wants to merge 4 commits intollimllib:masterfrom
dguido:master

Conversation

@dguido
Copy link
Copy Markdown

@dguido dguido commented Jan 20, 2015

This PR adds a simple business cat plugin. It watches for any text matching known business jargon and responds with a randomly chosen business cat image. Jargon and images were taken from hubot-business-cat (MIT licensed).

@llimllib
Copy link
Copy Markdown
Owner

Not ignoring you, btw, I just merged the tests branch, but I don't have plugin tests yet and I don't trust PRs until I do. Coming soon!

@dguido
Copy link
Copy Markdown
Author

dguido commented Jan 23, 2015

Oh cool you have tests now. I should start using those.

@topher200
Copy link
Copy Markdown
Collaborator

topher200 commented Oct 9, 2017

I spot checked ~6 of the imgur images and all their links still work! (go imgur!)


I started writing what a test file for plugin would be but I got hung up on a question: was this supposed to use re.match? ie: are we supposed to only match on input text that starts with a trigger phrase? It seems like re.search may have been the intended target (so we match if the trigger phrase is anywhere in the input text).

Certain triggers definitely seem like re.search was the intended behavior. See this trigger:

    "(\\W|^)buy(\\s|-)in",

That doesn't make much sense with re.match, but does with re.search.


Anyway, here's a start of what the plugin test file might look like (currently failing, see comment in file):

import os
import sys

DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(DIR, '../../limbo/plugins'))

from business_cat import on_message

def __we_get_response(text):
    ret = on_message({"text": text}, None)
    assert '.jpg' in ret

def test_business_cat():
    __we_get_response(u'action item')
    __we_get_response(u'action items')
    __we_get_response(u'action items extra words')
    __we_get_response(u'action items extra words')

    __we_get_response(u'buy in')

    ### these currently fail, due to re.match only matching on the start of an input phrase
    __we_get_response(u'get buy in')
    __we_get_response(u'get buy-in')
    __we_get_response(u'get buy-in extra words')

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