Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.

Commit 138c511

Browse files
committed
Add Command test
1 parent fbe10f9 commit 138c511

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/simple_slack_bot/command.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def initialize(bot_client)
77
end
88

99
def match?(str)
10-
(@regex.nil? || @regex.match(str).nil?) ? true : false
10+
(@regex.nil? || @regex.match(str).nil?) ? false : true
1111
end
1212

1313
def execute(data)

spec/command_spec.rb

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
1+
require 'spec_helper'
12

2-
# TODO
3+
describe SlackBot::Command do
4+
describe '#initialize' do
5+
bot = SlackBot::Client.new
6+
7+
it 'have a bot_client' do
8+
command = SlackBot::Command.new(bot)
9+
expect(command.bot_client).to eq bot
10+
end
11+
end
12+
13+
describe '.match?' do
14+
bot = SlackBot::Client.new
15+
bot.add_command('Hello')
16+
17+
it 'iterate commands' do
18+
bot.commands.each do |command|
19+
expect(command.regex).to eq 'Hello'
20+
end
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)