slack-ruby / slack-ruby-bot

The easiest way to write a Slack bot in Ruby.
MIT License
1.12k stars 187 forks source link

slack-ruby-bot rspec doesn't log no bot response properly. Reports undefined method count for nil:NilClass #234

Closed spkane closed 4 years ago

spkane commented 4 years ago

There seems to be a bug inslack-ruby-bot-0.12.0/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rbat this line message += @messages.count.zero? ? 'No response messages received' : @messages.inspect

In the example below you can see that the code throws a undefined method count for nil:NilClass error when there is no message instead of reporting that the No response messages received message to the user.

Failures:

  1) Bot listens for anything to do with VPN and refers user to help channel
     Failure/Error:
       expect(message: 'I am locked out of the vpn', channel: CHANNEL)
         .to respond_with_slack_message our_response

     NoMethodError:
       undefined method `count' for nil:NilClass
     # ./spec/8_bot_spec.rb:14:in `block (3 levels) in <top (required)>'

Finished in 0.53769 seconds (files took 0.93579 seconds to load)
47 examples, 1 failure
dblock commented 4 years ago

Please do fix, PRs welcome!

spkane commented 4 years ago

This has been fixed on master, but there has not been a proper gem release since the fix, so it would be nice to get that before we officially close this issue.

Would prefer to pin to an official release version instead of a branch or specific commit hash.

dblock commented 4 years ago

Which PR fixed this? Let's close it with that. I'll cut a release when I get to it.

spkane commented 4 years ago

@dblock It looks like you fixed it here:

https://github.com/slack-ruby/slack-ruby-bot/commit/e926d310923e58af151377fab9219ef899207697#diff-cfc9d257a3dc24179f3e707fee606d26R31