OperationCode / operationcode_bot

Slack bot for responding to Slack events and handling interactive messages. (not currently in use)
MIT License
8 stars 37 forks source link

Issue #58 Fix Attempt #60

Closed Cooperbuilt closed 7 years ago

Cooperbuilt commented 7 years ago

Changing the text formatting to a link format to make the name "clickable" in the "Notify Community" method.

Original => #{@user.name}

New Format => @#{@user.name}

This follows the "Hey <@U024BE7LH|bob>, did you see my file?" method for formatting links from the slack API documentation.

!!NOT TESTED!!

rickr commented 7 years ago

Hi @cooperbuilt

It looks like this has made some tests fail. Can you make sure they're all passing so I can merge?

rickr commented 7 years ago

Still looks like there's some failing tests. Check out the following locations: test/operationcode_bot_test.rb:96 test/lib/event/team_join_test.rb:26

Cooperbuilt commented 7 years ago

@rickr I have no earthly idea how to fix this. It keeps failing tests on what should be a simple formatting fix. Ive tested a bunch of variations and the current commit should work but doesn't seem to. If you have any suggestions, I am all ears.

rickr commented 7 years ago

No worries! I really appreciate you diving in on something out of your comfort zone! These failed tests are particularly hard to read so it's a bit of a double whammy!

I'm getting these failed tests from the travis build. Let's look at the first failed test (starts here: https://travis-ci.org/OperationCode/operationcode_bot/builds/239696463#L472)

Check out the following failed test:

FAIL["test_it_sends_a_message_to_the_user_if_an_env_var_is_set", Event::TeamJoinTest, 0.23507818600000974]
 test_it_sends_a_message_to_the_user_if_an_env_var_is_set#Event::TeamJoinTest (0.24s)
        unexpected invocation: Operationcode::Slack::Im.new(:channel => 'G3MD48QTD', :text => ':tada: <@FAKEUSERID> has joined the Slack team :tada:')
        unsatisfied expectations:
        - expected exactly once, not yet invoked: Operationcode::Slack::Im.new(:channel => 'G3MD48QTD', :text => ':tada: FAKE.USERNAME has joined the Slack team :tada:')
        satisfied expectations:
        - allowed any number of times, not yet invoked: #<AnyInstance:Event::TeamJoin>.user_exists?(any_parameters)
        - allowed any number of times, not yet invoked: #<Mock:0x1701858>.name(any_parameters)
        - allowed any number of times, invoked once: #<Mock:0x17003e0>.make_interactive_with!(any_parameters)
        - allowed any number of times, invoked once: #<Mock:0x17003e0>.deliver(any_parameters)
        - expected exactly once, invoked once: Operationcode::Slack::Im.new(:user => 'FAKEUSERID', :text => 'Hi FAKE.USERNAME,\n\nWelcome to Operation Code! I'm a bot designed to help answer questions and get you on your\nway in our community.\n\nOur goal here at Operation Code is to get veterans and their families started on the path to\na career in programming. We do that through providing you with scholarships, mentoring, career\ndevelopment opportunities, conference tickets, and more!\n\nYou're currently in Slack, a chat application that serves as the hub of Operation Code.\nIf you're currently visiting us via your browser Slack provides a stand alone program\nto make staying in touch even more convenient. You can download it here:\nhttps://slack.com/downloads\n\nBelow you'll see a list of topics. You can click on each topic to get more info. If you\nwant to see the topics again just reply to me with any message.\n\nWant to make your first change to a program right now? Click on the 'OpCode Challenge'\nbutton to get instructions on how to make a change to this very bot!\n')
        /app/lib/event/team_join.rb:36:in `notify_community!'
        /app/lib/event/team_join.rb:24:in `process'
        /app/test/lib/event/team_join_test.rb:26:in `test_it`_sends_a_message_to_the_user_if_an_env_var_is_set'
===Production mode: true
Welcoming user FAKEUSERID

There's a lot of superfluous info here but if we filter it out we see the following error:

unexpected invocation: Operationcode::Slack::Im.new(:channel => 'G3MD48QTD', :text => ':tada: <@FAKEUSERID> has joined the Slack team :tada:')
 unsatisfied expectations:
        - expected exactly once, not yet invoked: Operationcode::Slack::Im.new(:channel => 'G3MD48QTD', :text => ':tada: FAKE.USERNAME has joined the Slack team :tada:')

If we look at the test here, specifically this line our test is expecting a specific string (:tada: FAKE.USERNAME has joined the Slack team :tada:).

Your code change has changed that string, which is what we see in the unexpected invocation line above (:tada: <@FAKEUSERID> has joined the Slack team :tada:) and that's why the test is failing.

If you update that test with the new version of the welcome string it should pass.

Do you want to try to figure out the next one on your own? It looks like a similar issue at first glance.

Cooperbuilt commented 7 years ago

Thank you for being so kind in your comment! I am working on fixing the test, if I can get it passing, I will definitely try and tackle the next one. I want to familiarize myself as much as possible with Travis for future work.

Cooperbuilt commented 7 years ago

I think this should work now, at least it passes the eyeball test.

rickr commented 7 years ago

All tests are passing…great job!