slack-ruby / slack-ruby-bot

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

Tutorial Tests Broken #153

Closed wheresalice closed 7 years ago

wheresalice commented 7 years ago

I have followed the tutorial and the tests aren't actually testing anything it seems.

My command looks like this:

    class Calculate < SlackRubyBot::Commands::Base
      command 'calculate' do |client, data, _match|
        client.say(channel: data.channel, text: '3')
      end
    end

Note it's returning 3.

My tests look like this:

expect(message: "#{SlackRubyBot.config.user} calculate 2+2", channel: 'channel').to respond_with_slack_message('5')

Note it's expecting 2+2 to equal 5.

This test passes. 2+2 does not equal 3 or 5, so it should fail.

I'm running the tests with bundle exec rspec

The tests in dblock/slack-mathbot which this tutorial is apparently based on correctly fail if I try to expect 2+2 to equal 5.

dblock commented 7 years ago

I'm using these tests all the time with good success :) Care to put up a PR that reproduces this?

wheresalice commented 7 years ago

It turns out this was entirely my fault by naming the command specfile spec/slack-mathbot/commands/calculate.rb - ie missing out _spec in the filename and therefore it wasn't even loading it. My one passing test was in bot_spec.rb.

dblock commented 7 years ago

Glad it was something simple and that we were able to help!