slack-ruby-bot 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +6 -0
  5. data/.rubocop_todo.yml +41 -0
  6. data/.travis.yml +3 -0
  7. data/CHANGELOG.md +4 -0
  8. data/CONTRIBUTING.md +139 -0
  9. data/DEPLOYMENT.md +25 -0
  10. data/Gemfile +3 -0
  11. data/Gemfile.lock +107 -0
  12. data/LICENSE.md +22 -0
  13. data/README.md +69 -0
  14. data/Rakefile +19 -0
  15. data/examples/minimal/Gemfile +3 -0
  16. data/examples/minimal/Gemfile.lock +62 -0
  17. data/examples/minimal/pongbot.rb +14 -0
  18. data/lib/config/application.rb +14 -0
  19. data/lib/config/boot.rb +8 -0
  20. data/lib/config/environment.rb +3 -0
  21. data/lib/initializers/giphy.rb +3 -0
  22. data/lib/initializers/slack/request.rb +13 -0
  23. data/lib/slack-ruby-bot/about.rb +7 -0
  24. data/lib/slack-ruby-bot/app.rb +83 -0
  25. data/lib/slack-ruby-bot/commands/about.rb +9 -0
  26. data/lib/slack-ruby-bot/commands/base.rb +27 -0
  27. data/lib/slack-ruby-bot/commands/help.rb +9 -0
  28. data/lib/slack-ruby-bot/commands/hi.rb +9 -0
  29. data/lib/slack-ruby-bot/commands/unknown.rb +9 -0
  30. data/lib/slack-ruby-bot/commands.rb +5 -0
  31. data/lib/slack-ruby-bot/config.rb +13 -0
  32. data/lib/slack-ruby-bot/fixtures/slack/auth_test.yml +48 -0
  33. data/lib/slack-ruby-bot/hooks/base.rb +10 -0
  34. data/lib/slack-ruby-bot/hooks/hello.rb +11 -0
  35. data/lib/slack-ruby-bot/hooks/message.rb +41 -0
  36. data/lib/slack-ruby-bot/hooks.rb +3 -0
  37. data/lib/slack-ruby-bot/rspec/fixtures/slack/auth_test.yml +48 -0
  38. data/lib/slack-ruby-bot/rspec/support/fixtures/slack/auth_test.yml +103 -0
  39. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb +27 -0
  40. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb +31 -0
  41. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb +19 -0
  42. data/lib/slack-ruby-bot/rspec/support/slack_api_key.rb +5 -0
  43. data/lib/slack-ruby-bot/rspec/support/slack_ruby_bot_configure.rb +4 -0
  44. data/lib/slack-ruby-bot/rspec/support/vcr.rb +8 -0
  45. data/lib/slack-ruby-bot/rspec.rb +12 -0
  46. data/lib/slack-ruby-bot/version.rb +3 -0
  47. data/lib/slack-ruby-bot.rb +20 -0
  48. data/lib/slack_ruby_bot.rb +1 -0
  49. data/screenshots/register-bot.png +0 -0
  50. data/slack-ruby-bot.gemspec +27 -0
  51. data/spec/slack-ruby-bot/app_spec.rb +8 -0
  52. data/spec/slack-ruby-bot/commands/about_spec.rb +16 -0
  53. data/spec/slack-ruby-bot/commands/help_spec.rb +13 -0
  54. data/spec/slack-ruby-bot/commands/hi_spec.rb +13 -0
  55. data/spec/slack-ruby-bot/commands/unknown_spec.rb +17 -0
  56. data/spec/slack-ruby-bot/version_spec.rb +7 -0
  57. data/spec/spec_helper.rb +1 -0
  58. metadata +246 -0
@@ -0,0 +1,9 @@
1
+ module SlackRubyBot
2
+ module Commands
3
+ class Default < Base
4
+ def self.call(data, _command, _arguments)
5
+ send_message_with_gif data.channel, SlackRubyBot::ABOUT, 'selfie'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,27 @@
1
+ module SlackRubyBot
2
+ module Commands
3
+ class Base
4
+ def self.send_message(channel, text)
5
+ Slack.chat_postMessage(channel: channel, text: text)
6
+ end
7
+
8
+ def self.send_message_with_gif(channel, text, keywords)
9
+ gif = begin
10
+ Giphy.random(keywords)
11
+ rescue StandardError => e
12
+ logger.warn "Giphy.random: #{e.message}"
13
+ nil
14
+ end
15
+ text = text + "\n" + gif.image_url.to_s if gif
16
+ send_message channel, text
17
+ end
18
+
19
+ def self.logger
20
+ @logger ||= begin
21
+ $stdout.sync = true
22
+ Logger.new(STDOUT)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ module SlackRubyBot
2
+ module Commands
3
+ class Help < Base
4
+ def self.call(data, _command, _arguments)
5
+ send_message_with_gif data.channel, 'See https://github.com/dblock/slack-ruby-bot, please.', 'help'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module SlackRubyBot
2
+ module Commands
3
+ class Hi < Base
4
+ def self.call(data, _command, _arguments)
5
+ send_message_with_gif data.channel, "Hi <@#{data.user}>!", 'hi'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module SlackRubyBot
2
+ module Commands
3
+ class Unknown < Base
4
+ def self.call(data, _command, _arguments)
5
+ send_message_with_gif data.channel, "Sorry <@#{data.user}>, I don't understand that command!", 'idiot'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ require 'slack-ruby-bot/commands/base'
2
+ require 'slack-ruby-bot/commands/about'
3
+ require 'slack-ruby-bot/commands/help'
4
+ require 'slack-ruby-bot/commands/hi'
5
+ require 'slack-ruby-bot/commands/unknown'
@@ -0,0 +1,13 @@
1
+ module SlackRubyBot
2
+ module Config
3
+ extend self
4
+
5
+ attr_accessor :token
6
+ attr_accessor :url
7
+ attr_accessor :user
8
+ attr_accessor :user_id
9
+ attr_accessor :team
10
+ attr_accessor :team_id
11
+ attr_accessor :secret
12
+ end
13
+ end
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://slack.com/api/auth.test
6
+ body:
7
+ encoding: UTF-8
8
+ string: token=test
9
+ headers:
10
+ Accept:
11
+ - application/json; charset=utf-8
12
+ User-Agent:
13
+ - Slack Ruby Gem 1.1.6
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Access-Control-Allow-Origin:
24
+ - "*"
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Date:
28
+ - Thu, 02 Jul 2015 17:55:20 GMT
29
+ Server:
30
+ - Apache
31
+ Strict-Transport-Security:
32
+ - max-age=31536000; includeSubDomains; preload
33
+ Vary:
34
+ - Accept-Encoding
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ X-Xss-Protection:
38
+ - '0'
39
+ Content-Length:
40
+ - '55'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"ok":false,"error":"invalid_auth"}'
46
+ http_version:
47
+ recorded_at: Thu, 02 Jul 2015 17:55:48 GMT
48
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,10 @@
1
+ module SlackRubyBot
2
+ module Hooks
3
+ module Base
4
+ def included(caller)
5
+ caller.hooks ||= []
6
+ caller.hooks << name.demodulize.underscore.to_sym
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ module SlackRubyBot
2
+ module Hooks
3
+ module Hello
4
+ extend Base
5
+
6
+ def hello(_data)
7
+ logger.info "Successfully connected to #{SlackRubyBot.config.url}."
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,41 @@
1
+ module SlackRubyBot
2
+ module Hooks
3
+ module Message
4
+ extend Base
5
+
6
+ def message(data)
7
+ data = Hashie::Mash.new(data)
8
+ bot_name, command, arguments = parse_command(data.text)
9
+ return unless bot_name == SlackRubyBot.config.user
10
+ klass = command_to_class(command || 'Default')
11
+ klass.call data, command, arguments
12
+ end
13
+
14
+ private
15
+
16
+ def parse_command(text)
17
+ return unless text
18
+ text = '= ' + text[1..text.length] if text[0] == '='
19
+ parts = text.split.reject(&:blank?)
20
+ if parts && parts[0] == '='
21
+ parts[0] = SlackRubyBot.config.user
22
+ parts.insert 1, 'calculate'
23
+ end
24
+ [parts.first.downcase, parts[1].try(:downcase), parts[2..parts.length]] if parts && parts.any?
25
+ end
26
+
27
+ def command_classes(include_slack_ruby_bot = false)
28
+ klasses = SlackRubyBot::Commands::Base.descendants
29
+ klasses.reject! { |k| k.name.starts_with? 'SlackRubyBot::Commands::' } unless include_slack_ruby_bot
30
+ klasses
31
+ end
32
+
33
+ def command_to_class(command)
34
+ # prioritize implementations to built-in classes
35
+ klass = command_classes.detect { |d| d.name.ends_with? "::#{command.titleize}" }
36
+ klass ||= command_classes(true).detect { |d| d.name.ends_with? "::#{command.titleize}" }
37
+ klass || SlackRubyBot::Commands::Unknown
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ require 'slack-ruby-bot/hooks/base'
2
+ require 'slack-ruby-bot/hooks/hello'
3
+ require 'slack-ruby-bot/hooks/message'
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://slack.com/api/auth.test
6
+ body:
7
+ encoding: UTF-8
8
+ string: token=test
9
+ headers:
10
+ Accept:
11
+ - application/json; charset=utf-8
12
+ User-Agent:
13
+ - Slack Ruby Gem 1.1.6
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Access-Control-Allow-Origin:
24
+ - "*"
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Date:
28
+ - Thu, 02 Jul 2015 17:48:15 GMT
29
+ Server:
30
+ - Apache
31
+ Strict-Transport-Security:
32
+ - max-age=31536000; includeSubDomains; preload
33
+ Vary:
34
+ - Accept-Encoding
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ X-Xss-Protection:
38
+ - '0'
39
+ Content-Length:
40
+ - '55'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"ok":false,"error":"invalid_auth"}'
46
+ http_version:
47
+ recorded_at: Thu, 02 Jul 2015 17:48:42 GMT
48
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,103 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://slack.com/api/auth.test
6
+ body:
7
+ encoding: UTF-8
8
+ string: token=token
9
+ headers:
10
+ Accept:
11
+ - application/json; charset=utf-8
12
+ User-Agent:
13
+ - Slack Ruby Gem 1.1.1
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Access-Control-Allow-Origin:
24
+ - '*'
25
+ Cache-Control:
26
+ - private, no-cache, no-store, must-revalidate
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Date:
30
+ - Tue, 28 Apr 2015 12:55:23 GMT
31
+ Expires:
32
+ - Mon, 26 Jul 1997 05:00:00 GMT
33
+ Pragma:
34
+ - no-cache
35
+ Server:
36
+ - Apache
37
+ Strict-Transport-Security:
38
+ - max-age=31536000; includeSubDomains; preload
39
+ Vary:
40
+ - Accept-Encoding
41
+ X-Accepted-Oauth-Scopes:
42
+ - identify
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Oauth-Scopes:
46
+ - identify,read,post,client
47
+ X-Xss-Protection:
48
+ - '0'
49
+ Content-Length:
50
+ - '128'
51
+ Connection:
52
+ - keep-alive
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"ok":true,"url":"https:\/\/rubybot.slack.com\/","team":"team","user":"user","team_id":"TDEADBEEF","user_id":"UBAADFOOD"}'
56
+ http_version:
57
+ recorded_at: Tue, 28 Apr 2015 12:55:22 GMT
58
+ - request:
59
+ method: post
60
+ uri: https://slack.com/api/rtm.start
61
+ body:
62
+ encoding: UTF-8
63
+ string: token=token
64
+ headers:
65
+ Accept:
66
+ - application/json; charset=utf-8
67
+ User-Agent:
68
+ - Slack Ruby Gem 1.1.1
69
+ Content-Type:
70
+ - application/x-www-form-urlencoded
71
+ Accept-Encoding:
72
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: OK
77
+ headers:
78
+ Access-Control-Allow-Origin:
79
+ - '*'
80
+ Content-Type:
81
+ - application/json; charset=utf-8
82
+ Date:
83
+ - Tue, 28 Apr 2015 21:41:33 GMT
84
+ Server:
85
+ - Apache
86
+ Strict-Transport-Security:
87
+ - max-age=31536000; includeSubDomains; preload
88
+ Vary:
89
+ - Accept-Encoding
90
+ X-Content-Type-Options:
91
+ - nosniff
92
+ X-Xss-Protection:
93
+ - '0'
94
+ Content-Length:
95
+ - '55'
96
+ Connection:
97
+ - keep-alive
98
+ body:
99
+ encoding: UTF-8
100
+ string: '{"ok":false,"error":"invalid_auth"}'
101
+ http_version:
102
+ recorded_at: Tue, 28 Apr 2015 21:41:33 GMT
103
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,27 @@
1
+ shared_examples 'a slack ruby bot' do
2
+ context 'not configured' do
3
+ before do
4
+ @slack_api_token = ENV.delete('SLACK_API_TOKEN')
5
+ end
6
+ after do
7
+ ENV['SLACK_API_TOKEN'] = @slack_api_token
8
+ end
9
+ it 'requires SLACK_API_TOKEN' do
10
+ expect { subject }.to raise_error RuntimeError, "Missing ENV['SLACK_API_TOKEN']."
11
+ end
12
+ end
13
+ context 'configured', vcr: { cassette_name: 'auth_test' } do
14
+ context 'run' do
15
+ before do
16
+ subject.send(:auth!)
17
+ end
18
+ it 'succeeds auth' do
19
+ expect(subject.config.url).to eq 'https://rubybot.slack.com/'
20
+ expect(subject.config.team).to eq 'team'
21
+ expect(subject.config.user).to eq 'user'
22
+ expect(subject.config.team_id).to eq 'TDEADBEEF'
23
+ expect(subject.config.user_id).to eq 'UBAADFOOD'
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :respond_with_error do |expected|
4
+ match do |actual|
5
+ channel, user, message = parse(actual)
6
+ app = SlackRubyBot::App.new
7
+ SlackRubyBot.config.user = 'rubybot'
8
+ allow(Giphy).to receive(:random)
9
+ begin
10
+ expect do
11
+ app.send(:message, text: message, channel: channel, user: user)
12
+ end.to raise_error ArgumentError, expected
13
+ rescue RSpec::Expectations::ExpectationNotMetError => e
14
+ @error_message = e.message
15
+ raise e
16
+ end
17
+ true
18
+ end
19
+
20
+ failure_message do |actual|
21
+ _, _, message = parse(actual)
22
+ @error_message || "expected for '#{message}' to fail with '#{expected}'"
23
+ end
24
+
25
+ private
26
+
27
+ def parse(actual)
28
+ actual = { message: actual } unless actual.is_a?(Hash)
29
+ [actual[:channel] || 'channel', actual[:user] || 'user', actual[:message]]
30
+ end
31
+ end
@@ -0,0 +1,19 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :respond_with_slack_message do |expected|
4
+ match do |actual|
5
+ channel, user, message = parse(actual)
6
+ SlackRubyBot.config.user ||= 'rubybot'
7
+ allow(Giphy).to receive(:random)
8
+ expect(SlackRubyBot::Commands::Base).to receive(:send_message).with(channel, expected)
9
+ app.send(:message, text: message, channel: channel, user: user)
10
+ true
11
+ end
12
+
13
+ private
14
+
15
+ def parse(actual)
16
+ actual = { message: actual } unless actual.is_a?(Hash)
17
+ [actual[:channel] || 'channel', actual[:user] || 'user', actual[:message]]
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before :all do
3
+ ENV['SLACK_API_TOKEN'] ||= 'test'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ SlackRubyBot.configure do |config|
2
+ config.token = 'testtoken'
3
+ config.user = 'rubybot'
4
+ end
@@ -0,0 +1,8 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |config|
4
+ config.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures/slack')
5
+ config.hook_into :webmock
6
+ # config.default_cassette_options = { record: :new_episodes }
7
+ config.configure_rspec_metadata!
8
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
2
+
3
+ require 'rubygems'
4
+ require 'rspec'
5
+ require 'rack/test'
6
+
7
+ require 'config/environment'
8
+ require 'slack-ruby-bot'
9
+
10
+ Dir[File.join(File.dirname(__FILE__), 'rspec/support', '**/*.rb')].each do |file|
11
+ require file
12
+ end
@@ -0,0 +1,3 @@
1
+ module SlackRubyBot
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path('../config/environment', __FILE__)
2
+
3
+ require 'slack-ruby-bot/version'
4
+ require 'slack-ruby-bot/about'
5
+ require 'slack-ruby-bot/config'
6
+ require 'slack-ruby-bot/hooks'
7
+ require 'slack-ruby-bot/commands'
8
+ require 'slack-ruby-bot/app'
9
+
10
+ module SlackRubyBot
11
+ class << self
12
+ def configure
13
+ block_given? ? yield(Config) : Config
14
+ end
15
+
16
+ def config
17
+ Config
18
+ end
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ require 'slack-ruby-bot'
Binary file
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
+ require 'slack-ruby-bot/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'slack-ruby-bot'
6
+ s.version = SlackRubyBot::VERSION
7
+ s.authors = ['Daniel Doubrovkine']
8
+ s.email = 'dblock@dblock.org'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.required_rubygems_version = '>= 1.3.6'
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- spec/*`.split("\n")
13
+ s.require_paths = ['lib']
14
+ s.homepage = 'http://github.com/dblock/slack-ruby-bot'
15
+ s.licenses = ['MIT']
16
+ s.summary = 'Generic bot framework written in Ruby.'
17
+ s.add_dependency 'hashie'
18
+ s.add_dependency 'slack-api', '~> 1.1.6'
19
+ s.add_dependency 'activesupport'
20
+ s.add_dependency 'giphy', '~> 2.0.2'
21
+ s.add_development_dependency 'rake'
22
+ s.add_development_dependency 'rspec'
23
+ s.add_development_dependency 'rack-test'
24
+ s.add_development_dependency 'vcr'
25
+ s.add_development_dependency 'webmock'
26
+ s.add_development_dependency 'rubocop', '0.32.1'
27
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot::App do
4
+ def app
5
+ SlackRubyBot::App.new
6
+ end
7
+ it_behaves_like 'a slack ruby bot'
8
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot::Commands::Default do
4
+ def app
5
+ SlackRubyBot::App.new
6
+ end
7
+ before do
8
+ app.config.user = 'rubybot'
9
+ end
10
+ it 'rubybot' do
11
+ expect(message: 'rubybot').to respond_with_slack_message(SlackRubyBot::ABOUT)
12
+ end
13
+ it 'Rubybot' do
14
+ expect(message: 'Rubybot').to respond_with_slack_message(SlackRubyBot::ABOUT)
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot::Commands::Help do
4
+ def app
5
+ SlackRubyBot::App.new
6
+ end
7
+ before do
8
+ app.config.user = 'rubybot'
9
+ end
10
+ it 'help' do
11
+ expect(message: 'rubybot help').to respond_with_slack_message('See https://github.com/dblock/slack-ruby-bot, please.')
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot::Commands::Hi do
4
+ def app
5
+ SlackRubyBot::App.new
6
+ end
7
+ before do
8
+ app.config.user = 'rubybot'
9
+ end
10
+ it 'says hi' do
11
+ expect(message: 'rubybot hi').to respond_with_slack_message('Hi <@user>!')
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot::Commands::Unknown, vcr: { cassette_name: 'user_info' } do
4
+ def app
5
+ SlackRubyBot::App.new
6
+ end
7
+ before do
8
+ app.config.user = 'rubybot'
9
+ end
10
+ it 'invalid command' do
11
+ expect(message: 'rubybot foobar').to respond_with_slack_message("Sorry <@user>, I don't understand that command!")
12
+ end
13
+ it 'does not respond to sad face' do
14
+ expect(SlackRubyBot::Commands::Base).to_not receive(:send_message)
15
+ SlackRubyBot::App.new.send(:message, text: ':((')
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot do
4
+ it 'has a version' do
5
+ expect(SlackRubyBot::VERSION).to_not be nil
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require 'slack-ruby-bot/rspec'