slack-ruby-bot 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -1
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +2 -0
  5. data/README.md +53 -5
  6. data/UPGRADING.md +14 -2
  7. data/examples/market/Gemfile +1 -0
  8. data/examples/market/marketbot.rb +2 -0
  9. data/examples/minimal/Gemfile +1 -0
  10. data/examples/weather/Gemfile +1 -0
  11. data/examples/weather/weatherbot.rb +2 -0
  12. data/lib/slack-ruby-bot/about.rb +1 -1
  13. data/lib/slack-ruby-bot/app.rb +1 -1
  14. data/lib/slack-ruby-bot/commands/base.rb +2 -2
  15. data/lib/slack-ruby-bot/config.rb +1 -1
  16. data/lib/slack-ruby-bot/hooks.rb +2 -1
  17. data/lib/slack-ruby-bot/hooks/hello.rb +7 -3
  18. data/lib/slack-ruby-bot/hooks/hook_support.rb +37 -0
  19. data/lib/slack-ruby-bot/hooks/message.rb +2 -4
  20. data/lib/slack-ruby-bot/hooks/set.rb +45 -0
  21. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb +11 -3
  22. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb +10 -2
  23. data/lib/slack-ruby-bot/server.rb +15 -25
  24. data/lib/slack-ruby-bot/version.rb +1 -1
  25. data/slack-ruby-bot.gemspec +1 -2
  26. data/spec/slack-ruby-bot/commands/about_spec.rb +0 -3
  27. data/spec/slack-ruby-bot/commands/aliases_spec.rb +2 -8
  28. data/spec/slack-ruby-bot/commands/bot_spec.rb +2 -5
  29. data/spec/slack-ruby-bot/commands/commands_with_expression_spec.rb +1 -1
  30. data/spec/slack-ruby-bot/commands/direct_messages_spec.rb +2 -2
  31. data/spec/slack-ruby-bot/commands/empty_text_spec.rb +1 -6
  32. data/spec/slack-ruby-bot/commands/message_loop_spec.rb +6 -2
  33. data/spec/slack-ruby-bot/commands/nil_message_spec.rb +5 -4
  34. data/spec/slack-ruby-bot/commands/not_implemented_spec.rb +0 -3
  35. data/spec/slack-ruby-bot/commands/send_gif_spec.rb +5 -11
  36. data/spec/slack-ruby-bot/commands/send_message_spec.rb +1 -6
  37. data/spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb +16 -20
  38. data/spec/slack-ruby-bot/commands/unknown_spec.rb +4 -5
  39. data/spec/slack-ruby-bot/hooks/hook_support_spec.rb +47 -0
  40. data/spec/slack-ruby-bot/hooks/message_spec.rb +10 -8
  41. data/spec/slack-ruby-bot/hooks/set_spec.rb +56 -0
  42. data/spec/slack-ruby-bot/rspec/respond_with_error_spec.rb +1 -1
  43. data/spec/slack-ruby-bot/server_spec.rb +5 -5
  44. data/spec/spec_helper.rb +1 -0
  45. metadata +11 -20
  46. data/lib/slack-ruby-bot/hooks/base.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59c7b21c6857323515327cf3b14c4cd79bdfe25b
4
- data.tar.gz: ae4beccb7a8d933d2f7b6fffb170241fad4a85d4
3
+ metadata.gz: c8b86a027a9c17bbb4d3e69212493162aacfffca
4
+ data.tar.gz: 94ec098315fd7611325f567da9c5964d4847d47b
5
5
  SHA512:
6
- metadata.gz: 213767e2c36e1287e2916e24652b4ed873a3fb9bc84ff60e16bb7e6fcdf847d11dd622174421bed755febf65bf934bfc3000a3d3f0874afab7751b7c0bfc3db0
7
- data.tar.gz: aaff927afb06fce22a67e090bf4954cea920a383a84277bf681a00e5c29154f8ff66b5c9ed979625bd03b2a1cf1f79d28b9beb37e0d53fe370bc12aa49ef77da
6
+ metadata.gz: c97a004bbcfadbbd318158cc8ffe1d59637c7b0026139e771f655393cb362acd02adff508cff69a961781b5da25efa199756c326ca18f098fefc8f6ee85c4b6b
7
+ data.tar.gz: 15014981779338072114308822e4018d9bfc21b067f58689489ec2fffaec88b7fbf46a05a40a09d963c302da70d9312f9f0d08c42fe25a080ecfab2e78a171cc
@@ -1,3 +1,6 @@
1
1
  rvm:
2
- - 2.1.6
2
+ - 2.3.0
3
+ env:
4
+ - CONCURRENCY=celluloid-io
5
+ - CONCURRENCY=faye-websocket
3
6
 
@@ -1,3 +1,8 @@
1
+ ### 0.8.0 (5/5/2016)
2
+
3
+ * [#32](https://github.com/dblock/slack-ruby-bot/issues/32): Don't include `faye-websocket` by default, support `celluloid-io` - [@dblock](https://github.com/dblock).
4
+ * [#54](https://github.com/dblock/slack-ruby-bot/pull/54): Improvements to Hook configuration - [@dramalho](https://github.com/dramalho).
5
+
1
6
  ### 0.7.0 (3/6/2016)
2
7
 
3
8
  * Improved regular expression matching performance with less matching per command - [@dblock](https://github.com/dblock).
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem ENV['CONCURRENCY'], require: false if ENV.key?('CONCURRENCY')
data/README.md CHANGED
@@ -17,7 +17,7 @@ A generic Slack bot framework written in Ruby on top of [slack-ruby-client](http
17
17
 
18
18
  ## Stable Release
19
19
 
20
- You're reading the documentation for the **stable** release of slack-ruby-bot, 0.7.0. See [CHANGELOG](CHANGELOG.md) for a history of changes and [UPGRADING](UPGRADING.md) for how to upgrade to more recent versions.
20
+ You're reading the documentation for the **stable** release of slack-ruby-bot 0.8.0. See [CHANGELOG](CHANGELOG.md) for a history of changes and [UPGRADING](UPGRADING.md) for how to upgrade to more recent versions.
21
21
 
22
22
  ## Usage
23
23
 
@@ -26,9 +26,10 @@ You're reading the documentation for the **stable** release of slack-ruby-bot, 0
26
26
  #### Gemfile
27
27
 
28
28
  ```ruby
29
- source 'http://rubygems.org'
29
+ source 'https://rubygems.org'
30
30
 
31
31
  gem 'slack-ruby-bot'
32
+ gem 'celluloid-io'
32
33
  ```
33
34
 
34
35
  #### pongbot.rb
@@ -190,17 +191,39 @@ Get help.
190
191
 
191
192
  ### Hooks
192
193
 
193
- Hooks are event handlers and respond to Slack RTM API [events](https://api.slack.com/events), such as [hello](lib/slack-ruby-bot/hooks/hello.rb) or [message](lib/slack-ruby-bot/hooks/message.rb). You can implement your own by extending [SlackRubyBot::Hooks::Base](lib/slack-ruby-bot/hooks/base.rb).
194
+ Hooks are event handlers and respond to Slack RTM API [events](https://api.slack.com/events), such as [hello](lib/slack-ruby-bot/hooks/hello.rb) or [message](lib/slack-ruby-bot/hooks/message.rb). You can implement your own in a couple of ways:
195
+
196
+ #### Implement and register a Hook Handler
197
+
198
+ A Hook Handler is any object that respond to a `call` message, like a proc, instance of an object, class with a `call` class method, etc.
199
+
200
+ Hooks are registered onto the `SlackRubyBot::Server` instance, by way of a configuration hash
201
+
202
+ ```ruby
203
+ SlackRubyBot::Server.new(hook_handlers: {
204
+ hello: MyBot::Hooks::UserChange.new
205
+ })
206
+ ```
207
+
208
+ or at any time by pushing it to the `HookSet`
209
+
210
+ ```ruby
211
+ # Push an object that implements the
212
+ server.hooks.add(:hello, MyBot::Hooks::UserChange.new)
213
+
214
+ # Push a lambda to handle the event
215
+ server.hooks.add(:hello, ->(client, data) { puts "Hello!" })
216
+ ```
194
217
 
195
218
  For example, the following hook handles [user_change](https://api.slack.com/events/user_change), an event sent when a team member updates their profile or data. This can be useful to update the local user cache when a user is renamed.
196
219
 
197
220
  ```ruby
198
221
  module MyBot
199
222
  module Hooks
200
- module UserChange
223
+ class UserChange
201
224
  extend SlackRubyBot::Hooks::Base
202
225
 
203
- def user_change(client, data)
226
+ def call(client, data)
204
227
  # data['user']['id'] contains the user ID
205
228
  # data['user']['name'] contains the new user name
206
229
  ...
@@ -210,6 +233,23 @@ module MyBot
210
233
  end
211
234
  ```
212
235
 
236
+ Hooks can also be written as blocks inside the `SlackBotRuby::Server` class, for example
237
+
238
+ ```ruby
239
+ module MyBot
240
+ class MyServer < SlackRubyBot::Server
241
+ on 'hello' do |client, data|
242
+ # data['user']['id'] contains the user ID
243
+ # data['user']['name'] contains the new user name
244
+ end
245
+ end
246
+ end
247
+ ```
248
+
249
+ These will get pushed into the hook set on initialization.
250
+
251
+ Either by configuration, explicit assignment or hook blocks, multiple handlers can exist for the same event type.
252
+
213
253
  ### Disable Animated GIFs
214
254
 
215
255
  By default bots send animated GIFs in default commands and errors. To disable animated GIFs set `send_gifs` or `ENV['SLACK_RUBY_BOT_SEND_GIFS']` to `false`.
@@ -230,6 +270,14 @@ SlackRubyBot.configure do |config|
230
270
  end
231
271
  ```
232
272
 
273
+ ### Logging
274
+
275
+ By default bots set a logger to `STDOUT` with `DEBUG` level. The logger is used in both the RealTime and Web clients. Silence logger as follows.
276
+
277
+ ```ruby
278
+ SlackRubyBot::Client.logger.level = Logger::WARN
279
+ ```
280
+
233
281
  ### Advanced Integration
234
282
 
235
283
  You may want to integrate a bot or multiple bots into other systems, in which case a globally configured bot may not work for you. You may create instances of [SlackRubyBot::Server](lib/slack-ruby-bot/server.rb) which accepts `token`, `aliases` and `send_gifs`.
@@ -1,6 +1,20 @@
1
1
  Upgrading SlackRubyBot
2
2
  ======================
3
3
 
4
+ ### Upgrading to >= 0.8.0
5
+
6
+ #### Require a concurrency library
7
+
8
+ The `faye-websocket` library is no longer required by default. Add either `faye-websocket` or `celluiloid-io` to your `Gemfile` depending on which concurrency implementation you'd like to use. We recommend `celluloid-io` moving forward.
9
+
10
+ #### Hook::Base was removed, explicitly register any custom hook classes
11
+
12
+ Hook classes are now handled differently, namely they are explicitly registered into `SlackRubyBot::Server` via a configuration option (`hook_handlers`) or by passing a similar hash later on through the `add_hook_handlers` method. Including Hook classes directly into the server class is no longer needed.
13
+
14
+ A hook is actioned via a `call` message onto the handler object (this can be anything that responds to that), so you'll need to rename your method.
15
+
16
+ Finally, you can now register multiple hooks for the same event, so if you had any code to remove default hooks, you'll need to change it so you pass a configuration hash into `Server`
17
+
4
18
  ### Upgrading to >= 0.7.0
5
19
 
6
20
  #### Simplify Match Expression Checking
@@ -175,5 +189,3 @@ def self.call(client, data, match)
175
189
  send_message_with_gif client, data.channel, 'hello', 'hi'
176
190
  end
177
191
  ```
178
-
179
-
@@ -1,4 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'slack-ruby-bot', path: '../..'
4
+ gem 'faye-websocket'
4
5
  gem 'yahoo-finance'
@@ -1,6 +1,8 @@
1
1
  require 'slack-ruby-bot'
2
2
  require 'yahoo-finance'
3
3
 
4
+ SlackRubyBot::Client.logger.level = Logger::WARN
5
+
4
6
  class MarketBot < SlackRubyBot::Bot
5
7
  scan(/([A-Z]{2,5}+)/) do |client, data, stocks|
6
8
  YahooFinance::Client.new.quotes(stocks, [:name, :symbol, :last_trade_price, :change, :change_in_percent]).each do |quote|
@@ -1,3 +1,4 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'slack-ruby-bot', path: '../..'
4
+ gem 'celluloid-io'
@@ -1,3 +1,4 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'slack-ruby-bot', path: '../..'
4
+ gem 'celluloid-io'
@@ -1,5 +1,7 @@
1
1
  require 'slack-ruby-bot'
2
2
 
3
+ SlackRubyBot::Client.logger.level = Logger::WARN
4
+
3
5
  class WeatherBot < SlackRubyBot::Bot
4
6
  match(/^How is the weather in (?<location>\w*)\?$/i) do |client, data, match|
5
7
  client.say(channel: data.channel, text: "The weather in #{match[:location]} is nice.")
@@ -1,5 +1,5 @@
1
1
  module SlackRubyBot
2
- ABOUT = <<-ABOUT
2
+ ABOUT = <<-ABOUT.freeze
3
3
  #{SlackRubyBot::VERSION}
4
4
  https://github.com/dblock/slack-ruby-bot
5
5
  https://twitter.com/dblockdotorg
@@ -2,7 +2,7 @@ module SlackRubyBot
2
2
  class App < Server
3
3
  def initialize(options = {})
4
4
  SlackRubyBot.configure do |config|
5
- config.token = ENV['SLACK_API_TOKEN'] || fail("Missing ENV['SLACK_API_TOKEN'].")
5
+ config.token = ENV['SLACK_API_TOKEN'] || raise("Missing ENV['SLACK_API_TOKEN'].")
6
6
  config.aliases = ENV['SLACK_RUBY_BOT_ALIASES'].split(' ') if ENV['SLACK_RUBY_BOT_ALIASES']
7
7
  end
8
8
  Slack.configure do |config|
@@ -7,7 +7,7 @@ module SlackRubyBot
7
7
  class << self
8
8
  def send_message(client, channel, text, options = {})
9
9
  logger.warn '[DEPRECATION] `send_message` is deprecated. Please use `client.say` instead.'
10
- if text && text.length > 0
10
+ if text && !text.length.empty?
11
11
  client.say(options.merge(channel: channel, text: text))
12
12
  else
13
13
  client.say(options.merge(channel: channel, text: 'Nothing to see here.', gif: 'nothing'))
@@ -61,7 +61,7 @@ module SlackRubyBot
61
61
  elsif respond_to?(:call)
62
62
  send(:call, client, data, match)
63
63
  else
64
- fail NotImplementedError, data.text
64
+ raise NotImplementedError, data.text
65
65
  end
66
66
  break
67
67
  end if expression
@@ -30,7 +30,7 @@ module SlackRubyBot
30
30
  when 1, 'true', 'yes'
31
31
  true
32
32
  else
33
- fail ArgumentError, "Invalid value for #{key}: #{value}."
33
+ raise ArgumentError, "Invalid value for #{key}: #{value}."
34
34
  end
35
35
  end
36
36
  end
@@ -1,3 +1,4 @@
1
- require 'slack-ruby-bot/hooks/base'
1
+ require 'slack-ruby-bot/hooks/set'
2
2
  require 'slack-ruby-bot/hooks/hello'
3
3
  require 'slack-ruby-bot/hooks/message'
4
+ require 'slack-ruby-bot/hooks/hook_support'
@@ -1,9 +1,13 @@
1
1
  module SlackRubyBot
2
2
  module Hooks
3
- module Hello
4
- extend Base
3
+ class Hello
4
+ attr_accessor :logger
5
5
 
6
- def hello(client, _data)
6
+ def initialize(logger)
7
+ self.logger = logger
8
+ end
9
+
10
+ def call(client, _data)
7
11
  return unless client && client.team
8
12
  logger.info "Successfully connected to https://#{client.team.domain}.slack.com."
9
13
  end
@@ -0,0 +1,37 @@
1
+ module SlackRubyBot
2
+ module Hooks
3
+ module HookSupport
4
+ def self.included(base)
5
+ base.cattr_accessor :hook_blocks
6
+
7
+ base.extend(ClassMethods)
8
+ end
9
+
10
+ module ClassMethods
11
+ def on(event_name, &block)
12
+ self.hook_blocks ||= {}
13
+
14
+ self.hook_blocks[event_name] ||= []
15
+ self.hook_blocks[event_name] << block
16
+ end
17
+ end
18
+
19
+ # Instance stuff
20
+ def hooks
21
+ @hooks ||= SlackRubyBot::Hooks::Set.new
22
+ end
23
+
24
+ def flush_hook_blocks
25
+ return nil unless self.class.hook_blocks
26
+
27
+ add_hook_handlers(self.class.hook_blocks)
28
+ end
29
+
30
+ def add_hook_handlers(handler_hash)
31
+ handler_hash.each do |hook, handlers|
32
+ Array(handlers).each { |handler| hooks.add(hook, handler) }
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,9 +1,7 @@
1
1
  module SlackRubyBot
2
2
  module Hooks
3
- module Message
4
- extend Base
5
-
6
- def message(client, data)
3
+ class Message
4
+ def call(client, data)
7
5
  return if message_to_self_not_allowed? && message_to_self?(client, data)
8
6
  data.text.strip! if data.text
9
7
  result = child_command_classes.detect { |d| d.invoke(client, data) }
@@ -0,0 +1,45 @@
1
+ module SlackRubyBot
2
+ module Hooks
3
+ class Set
4
+ attr_accessor :handlers, :client
5
+
6
+ def initialize(client = nil)
7
+ self.handlers = {}
8
+ self.client = client
9
+
10
+ @pending_flush = client.blank?
11
+ end
12
+
13
+ def add(hook_name, handler)
14
+ if handlers[hook_name].present?
15
+ handlers[hook_name] << handler
16
+ else
17
+ handlers[hook_name] = [handler]
18
+ register_callback(hook_name)
19
+ end
20
+ end
21
+
22
+ def client=(client)
23
+ @client = client
24
+
25
+ flush_handlers if @pending_flush
26
+ end
27
+
28
+ protected
29
+
30
+ def register_callback(hook_name)
31
+ return unless client # We'll delay this until client is set
32
+
33
+ client.on hook_name do |data|
34
+ handlers[hook_name].each do |handler|
35
+ handler.call(client, data)
36
+ end
37
+ end
38
+ end
39
+
40
+ def flush_handlers
41
+ handlers.keys.each { |hook| register_callback(hook) }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -2,12 +2,20 @@ require 'rspec/expectations'
2
2
 
3
3
  RSpec::Matchers.define :respond_with_error do |error, error_message|
4
4
  match do |actual|
5
- channel, user, message = parse(actual)
6
5
  allow(Giphy).to receive(:random)
6
+
7
+ client = if respond_to?(:client)
8
+ send(:client)
9
+ else
10
+ SlackRubyBot::Client.new
11
+ end
12
+
13
+ message_command = SlackRubyBot::Hooks::Message.new
14
+ channel, user, message = parse(actual)
15
+
7
16
  begin
8
17
  expect do
9
- client = app.send(:client)
10
- app.send(:message, client, Hashie::Mash.new(text: message, channel: channel, user: user))
18
+ message_command.call(client, Hashie::Mash.new(text: message, channel: channel, user: user))
11
19
  end.to raise_error error, error_message
12
20
  rescue RSpec::Expectations::ExpectationNotMetError => e
13
21
  @error_message = e.message
@@ -2,11 +2,19 @@ require 'rspec/expectations'
2
2
 
3
3
  RSpec::Matchers.define :respond_with_slack_message do |expected|
4
4
  match do |actual|
5
+ client = if respond_to?(:client)
6
+ send(:client)
7
+ else
8
+ SlackRubyBot::Client.new
9
+ end
10
+
11
+ message_command = SlackRubyBot::Hooks::Message.new
12
+
5
13
  channel, user, message = parse(actual)
6
14
  allow(Giphy).to receive(:random)
7
- client = app.send(:client)
15
+
8
16
  expect(client).to receive(:message).with(channel: channel, text: expected)
9
- app.send(:message, client, Hashie::Mash.new(text: message, channel: channel, user: user))
17
+ message_command.call(client, Hashie::Mash.new(text: message, channel: channel, user: user))
10
18
  true
11
19
  end
12
20
 
@@ -1,23 +1,30 @@
1
1
  module SlackRubyBot
2
2
  class Server
3
3
  include Loggable
4
- cattr_accessor :hooks
4
+
5
5
  attr_accessor :token, :aliases, :send_gifs
6
6
 
7
- TRAPPED_SIGNALS = %w(INT TERM).freeze
7
+ include SlackRubyBot::Hooks::HookSupport
8
8
 
9
- include SlackRubyBot::Hooks::Hello
10
- include SlackRubyBot::Hooks::Message
9
+ TRAPPED_SIGNALS = %w(INT TERM).freeze
11
10
 
12
11
  def initialize(options = {})
13
12
  @token = options[:token]
14
13
  @aliases = options[:aliases]
15
14
  @send_gifs = options.key?(:send_gifs) ? !!options[:send_gifs] : true
15
+
16
+ # Hook Handling
17
+ flush_hook_blocks
18
+
19
+ add_hook_handlers options[:hook_handlers] || {
20
+ hello: SlackRubyBot::Hooks::Hello.new(logger),
21
+ message: SlackRubyBot::Hooks::Message.new
22
+ }
16
23
  end
17
24
 
18
25
  def run
19
26
  loop do
20
- handle_execeptions do
27
+ handle_exceptions do
21
28
  handle_signals
22
29
  start!
23
30
  end
@@ -41,11 +48,6 @@ module SlackRubyBot
41
48
  client.stop! if @client
42
49
  end
43
50
 
44
- def hello!
45
- return unless client.self && client.team
46
- logger.info "Welcome '#{client.self.name}' to the '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
47
- end
48
-
49
51
  def restart!(wait = 1)
50
52
  @async ? start_async : start!
51
53
  rescue StandardError => e
@@ -57,7 +59,7 @@ module SlackRubyBot
57
59
 
58
60
  private
59
61
 
60
- def handle_execeptions
62
+ def handle_exceptions
61
63
  yield
62
64
  rescue Slack::Web::Api::Error => e
63
65
  logger.error e
@@ -93,20 +95,8 @@ module SlackRubyBot
93
95
  @client = nil
94
96
  restart! unless @stopping
95
97
  end
96
- hooks.each do |hook|
97
- client.on hook do |data|
98
- begin
99
- send hook, client, data
100
- rescue StandardError => e
101
- logger.error e
102
- begin
103
- client.message(channel: data['channel'], text: e.message) if data.key?('channel')
104
- rescue
105
- # ignore
106
- end
107
- end
108
- end
109
- end
98
+ hooks.client = client
99
+
110
100
  client
111
101
  end
112
102
  end
@@ -1,3 +1,3 @@
1
1
  module SlackRubyBot
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'.freeze
3
3
  end
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.summary = 'The easiest way to write a Slack bot in Ruby.'
17
17
  s.add_dependency 'hashie'
18
18
  s.add_dependency 'slack-ruby-client', '>= 0.6.0'
19
- s.add_dependency 'faye-websocket'
20
19
  s.add_dependency 'activesupport'
21
20
  s.add_dependency 'giphy', '~> 2.0.2'
22
21
  s.add_development_dependency 'rake'
@@ -24,5 +23,5 @@ Gem::Specification.new do |s|
24
23
  s.add_development_dependency 'rack-test'
25
24
  s.add_development_dependency 'vcr'
26
25
  s.add_development_dependency 'webmock'
27
- s.add_development_dependency 'rubocop', '0.32.1'
26
+ s.add_development_dependency 'rubocop', '0.38.0'
28
27
  end
@@ -1,9 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SlackRubyBot::Commands::Default do
4
- def app
5
- SlackRubyBot::App.new
6
- end
7
4
  it 'lowercase' do
8
5
  expect(message: SlackRubyBot.config.user).to respond_with_slack_message(SlackRubyBot::ABOUT)
9
6
  end
@@ -1,14 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SlackRubyBot do
4
- def app
5
- SlackRubyBot::App.new
6
- end
7
- before do
8
- ENV['SLACK_RUBY_BOT_ALIASES'] = ':emoji: alias каспаров'
9
- end
10
- after do
11
- ENV.delete('SLACK_RUBY_BOT_ALIASES')
4
+ def client
5
+ SlackRubyBot::Client.new aliases: %w(:emoji: alias каспаров)
12
6
  end
13
7
  it 'responds to emoji' do
14
8
  expect(message: ':emoji: hi').to respond_with_slack_message('Hi <@user>!')
@@ -8,14 +8,11 @@ describe SlackRubyBot::Bot do
8
8
  end
9
9
  end
10
10
  end
11
+
11
12
  def app
12
13
  SlackRubyBot::Bot.instance
13
14
  end
14
- let(:client) { app.send(:client) }
15
- it 'sends a message' do
16
- expect(client).to receive(:message).with(channel: 'channel', text: 'message')
17
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} bot_spec message", channel: 'channel', user: 'user'))
18
- end
15
+
19
16
  it 'sends a message' do
20
17
  expect(message: "#{SlackRubyBot.config.user} bot_spec message").to respond_with_slack_message('message')
21
18
  end
@@ -8,7 +8,7 @@ describe SlackRubyBot::Commands do
8
8
  k, v = match['expression'].split(/\W+/, 2)
9
9
  client.say(channel: data.channel, text: "#{match[:command]}: #{k}=#{v}")
10
10
  else
11
- client.say(channel: data.channel, text: "#{match[:command]}")
11
+ client.say(channel: data.channel, text: (match[:command]).to_s)
12
12
  end
13
13
  end
14
14
  end
@@ -20,10 +20,10 @@ describe SlackRubyBot do
20
20
  end
21
21
  context 'it responds to direct name calling' do
22
22
  it 'with bot name' do
23
- expect(message: "#{SlackRubyBot.config.user}", channel: 'DEADBEEF').to respond_with_slack_message(SlackRubyBot::ABOUT)
23
+ expect(message: SlackRubyBot.config.user.to_s, channel: 'DEADBEEF').to respond_with_slack_message(SlackRubyBot::ABOUT)
24
24
  end
25
25
  it 'with bot name capitalized' do
26
- expect(message: "#{SlackRubyBot.config.user.upcase}", channel: 'DEADBEEF').to respond_with_slack_message(SlackRubyBot::ABOUT)
26
+ expect(message: SlackRubyBot.config.user.upcase.to_s, channel: 'DEADBEEF').to respond_with_slack_message(SlackRubyBot::ABOUT)
27
27
  end
28
28
  it 'with bot user id' do
29
29
  expect(message: "<@#{SlackRubyBot.config.user_id}>", channel: 'DEADBEEF').to respond_with_slack_message(SlackRubyBot::ABOUT)
@@ -10,13 +10,8 @@ describe SlackRubyBot::Commands do
10
10
  end
11
11
  end
12
12
  end
13
- def app
14
- SlackRubyBot::App.new
15
- end
16
- let(:client) { app.send(:client) }
17
13
  it 'sends default text' do
18
14
  allow(Giphy).to receive(:random)
19
- expect(client).to receive(:message).with(channel: 'channel', text: '')
20
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} empty_text", channel: 'channel', user: 'user'))
15
+ expect(message: "#{SlackRubyBot.config.user} empty_text", channel: 'channel', user: 'user').to respond_with_slack_message('')
21
16
  end
22
17
  end
@@ -4,15 +4,19 @@ describe SlackRubyBot::App do
4
4
  def app
5
5
  SlackRubyBot::App.new
6
6
  end
7
+
7
8
  let(:client) { subject.send(:client) }
9
+ let(:message_hook) { SlackRubyBot::Hooks::Message.new }
10
+
8
11
  before do
9
12
  allow(client).to receive(:self).and_return(Hashie::Mash.new('id' => 'UDEADBEEF'))
10
13
  allow(Giphy).to receive(:random)
11
14
  end
15
+
12
16
  context 'default' do
13
17
  it 'does not respond to self' do
14
18
  expect(client).to_not receive(:message)
15
- subject.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} hi", channel: 'channel', user: 'UDEADBEEF'))
19
+ message_hook.call(client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} hi", channel: 'channel', user: 'UDEADBEEF'))
16
20
  end
17
21
  end
18
22
  context 'with allow_message_loops=true' do
@@ -28,7 +32,7 @@ describe SlackRubyBot::App do
28
32
  end
29
33
  it 'responds to self' do
30
34
  expect(client).to receive(:message)
31
- subject.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} hi", channel: 'channel', user: 'UDEADBEEF'))
35
+ message_hook.call(client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} hi", channel: 'channel', user: 'UDEADBEEF'))
32
36
  end
33
37
  end
34
38
  end
@@ -10,13 +10,14 @@ describe SlackRubyBot::Commands do
10
10
  end
11
11
  end
12
12
  end
13
- def app
14
- SlackRubyBot::App.new
15
- end
13
+
14
+ let(:app) { SlackRubyBot::App.new }
16
15
  let(:client) { app.send(:client) }
16
+ let(:message_hook) { SlackRubyBot::Hooks::Message.new }
17
+
17
18
  it 'ignores nil messages' do
18
19
  allow(Giphy).to receive(:random)
19
20
  expect(client).to_not receive(:message)
20
- app.send(:message, client, Hashie::Mash.new(text: nil, channel: 'channel', user: 'user'))
21
+ message_hook.call(client, Hashie::Mash.new(text: nil, channel: 'channel', user: 'user'))
21
22
  end
22
23
  end
@@ -6,9 +6,6 @@ describe SlackRubyBot::Commands::Base do
6
6
  command 'not_implemented'
7
7
  end
8
8
  end
9
- def app
10
- SlackRubyBot::App.new
11
- end
12
9
  it 'raises not implemented' do
13
10
  expect(message: "#{SlackRubyBot.config.user} not_implemented").to respond_with_error(NotImplementedError, 'rubybot not_implemented')
14
11
  end
@@ -8,25 +8,19 @@ describe SlackRubyBot::Commands do
8
8
  end
9
9
  end
10
10
  end
11
- def app
12
- SlackRubyBot::App.new
13
- end
14
- let(:client) { app.send(:client) }
11
+
15
12
  let(:gif_image_url) { 'http://media2.giphy.com/media/pzOijFsdDrsS4/giphy.gif' }
16
13
  it 'sends a gif' do
17
14
  gif = Giphy::RandomGif.new('image_url' => gif_image_url)
18
15
  expect(Giphy).to receive(:random).and_return(gif)
19
- expect(client).to receive(:message).with(channel: 'channel', text: gif_image_url)
20
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_gif_spec message", channel: 'channel', user: 'user'))
16
+ expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message(gif_image_url)
21
17
  end
22
18
  it 'eats up the error' do
23
- expect(Giphy).to receive(:random) { fail 'oh no!' }
24
- expect(client).to receive(:message).with(channel: 'channel', text: '')
25
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_gif_spec message", channel: 'channel', user: 'user'))
19
+ expect(Giphy).to receive(:random) { raise 'oh no!' }
20
+ expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message('')
26
21
  end
27
22
  it 'eats up nil gif' do
28
23
  expect(Giphy).to receive(:random).and_return(nil)
29
- expect(client).to receive(:message).with(channel: 'channel', text: '')
30
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_gif_spec message", channel: 'channel', user: 'user'))
24
+ expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message('')
31
25
  end
32
26
  end
@@ -8,12 +8,7 @@ describe SlackRubyBot::Commands do
8
8
  end
9
9
  end
10
10
  end
11
- def app
12
- SlackRubyBot::App.new
13
- end
14
- let(:client) { app.send(:client) }
15
11
  it 'sends a message' do
16
- expect(client).to receive(:message).with(channel: 'channel', text: 'message')
17
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_message_spec message", channel: 'channel', user: 'user'))
12
+ expect(message: "#{SlackRubyBot.config.user} send_message_spec message").to respond_with_slack_message('message')
18
13
  end
19
14
  end
@@ -8,62 +8,58 @@ describe SlackRubyBot::Commands do
8
8
  end
9
9
  end
10
10
  end
11
- def app
12
- SlackRubyBot::App.new
13
- end
14
- let(:client) { app.send(:client) }
15
11
  let(:gif_image_url) { 'http://media2.giphy.com/media/pzOijFsdDrsS4/giphy.gif' }
12
+
16
13
  it 'sends a message with gif' do
17
14
  gif = Giphy::RandomGif.new('image_url' => gif_image_url)
18
15
  expect(Giphy).to receive(:random).and_return(gif)
19
- expect(client).to receive(:message).with(channel: 'channel', text: "message\n#{gif_image_url}")
20
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user'))
16
+ expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message("message\n#{gif_image_url}")
21
17
  end
18
+
22
19
  it 'eats up the error' do
23
- expect(Giphy).to receive(:random) { fail 'oh no!' }
24
- expect(client).to receive(:message).with(channel: 'channel', text: 'message')
25
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user'))
20
+ expect(Giphy).to receive(:random) { raise 'oh no!' }
21
+ expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
26
22
  end
23
+
27
24
  it 'eats up nil gif' do
28
25
  expect(Giphy).to receive(:random).and_return(nil)
29
- expect(client).to receive(:message).with(channel: 'channel', text: 'message')
30
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user'))
26
+ expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
31
27
  end
28
+
32
29
  context 'send_gifs' do
33
30
  context 'set to false via client' do
31
+ let(:client) { SlackRubyBot::Client.new }
32
+
34
33
  before do
35
34
  client.send_gifs = false
36
35
  end
36
+
37
37
  it 'does not send a gif' do
38
38
  expect(Giphy).to_not receive(:random)
39
- expect(client).to receive(:message).with(channel: 'channel', text: 'message')
40
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user'))
41
- end
42
- after do
43
- client.send_gifs = true
39
+ expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
44
40
  end
45
41
  end
42
+
46
43
  context 'set to false via config' do
47
44
  before do
48
45
  SlackRubyBot::Config.send_gifs = false
49
46
  end
50
47
  it 'does not send a gif' do
51
48
  expect(Giphy).to_not receive(:random)
52
- expect(client).to receive(:message).with(channel: 'channel', text: 'message')
53
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user'))
49
+ expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
54
50
  end
55
51
  after do
56
52
  SlackRubyBot::Config.reset!
57
53
  end
58
54
  end
55
+
59
56
  context 'set to false via SLACK_RUBY_BOT_SEND_GIFS' do
60
57
  before do
61
58
  ENV['SLACK_RUBY_BOT_SEND_GIFS'] = 'false'
62
59
  end
63
60
  it 'does not send a gif' do
64
61
  expect(Giphy).to_not receive(:random)
65
- expect(client).to receive(:message).with(channel: 'channel', text: 'message')
66
- app.send(:message, client, Hashie::Mash.new(text: "#{SlackRubyBot.config.user} send_message_with_gif_spec message", channel: 'channel', user: 'user'))
62
+ expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
67
63
  end
68
64
  after do
69
65
  ENV.delete 'SLACK_RUBY_BOT_SEND_GIFS'
@@ -1,10 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SlackRubyBot::Commands::Unknown do
4
- def app
5
- SlackRubyBot::App.new
6
- end
7
- let(:client) { app.send(:client) }
8
4
  it 'invalid command' do
9
5
  expect(message: "#{SlackRubyBot.config.user} foobar").to respond_with_slack_message("Sorry <@user>, I don't understand that command!")
10
6
  end
@@ -12,7 +8,10 @@ describe SlackRubyBot::Commands::Unknown do
12
8
  expect(message: "<@#{SlackRubyBot.config.user_id}>: foobar").to respond_with_slack_message("Sorry <@user>, I don't understand that command!")
13
9
  end
14
10
  it 'does not respond to sad face' do
11
+ client = SlackRubyBot::Client.new
12
+ message_hook = SlackRubyBot::Hooks::Message.new
13
+
15
14
  expect(SlackRubyBot::Commands::Base).to_not receive(:send_message)
16
- SlackRubyBot::App.new.send(:message, client, Hashie::Mash.new(text: ':(('))
15
+ message_hook.call(client, Hashie::Mash.new(text: ':((', channel: 'channel', user: 'user'))
17
16
  end
18
17
  end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot::Hooks::HookSupport do
4
+ subject do
5
+ Class.new do
6
+ include SlackRubyBot::Hooks::HookSupport
7
+
8
+ on 'hello' do |_ = nil, _ = nil|
9
+ 'hello'
10
+ end
11
+
12
+ on 'hello' do |_ = nil, _ = nil|
13
+ 'hello-2'
14
+ end
15
+
16
+ on 'goodbye' do |_ = nil, _ = nil|
17
+ 'goodbye'
18
+ end
19
+ end
20
+ end
21
+
22
+ describe 'hook code blocks' do
23
+ it "let's you define class level code blocks" do
24
+ expect(subject.hook_blocks.size).to eq(2)
25
+ expect(subject.hook_blocks.keys).to eq %w(hello goodbye)
26
+
27
+ expect(subject.hook_blocks['hello'].size).to eq(2)
28
+ expect(subject.hook_blocks['goodbye'].size).to eq(1)
29
+
30
+ expect(subject.hook_blocks['hello'].first.call).to eq('hello')
31
+ expect(subject.hook_blocks['hello'].last.call).to eq('hello-2')
32
+ expect(subject.hook_blocks['goodbye'].last.call).to eq('goodbye')
33
+ end
34
+ end
35
+
36
+ describe '#flush_hook_blocks' do
37
+ it 'registers class hook blocks as hook handlers in set' do
38
+ object = subject.new
39
+
40
+ expect(object.hooks).to receive(:add).exactly(3).times.and_call_original
41
+
42
+ expect do
43
+ object.flush_hook_blocks
44
+ end.to change { object.hooks.handlers.size }.by(2)
45
+ end
46
+ end
47
+ end
@@ -1,16 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SlackRubyBot::Hooks::Message do
4
- let(:server) { SlackRubyBot::Server.new }
4
+ let(:message_hook) { described_class.new }
5
+
5
6
  describe '#child_command_classes' do
6
7
  it 'returns only child command classes' do
7
- child_command_classes = server.send(:child_command_classes)
8
+ child_command_classes = message_hook.send(:child_command_classes)
8
9
  expect(child_command_classes).to include SlackRubyBot::Bot
9
10
  expect(child_command_classes).to_not include SlackRubyBot::Commands::Hi
10
11
  end
11
12
  end
13
+
12
14
  describe '#built_in_command_classes' do
13
- let(:built_in_command_classes) { server.send(:built_in_command_classes) }
15
+ let(:built_in_command_classes) { message_hook.send(:built_in_command_classes) }
14
16
  it 'returns only built in command classes' do
15
17
  expect(built_in_command_classes).to include SlackRubyBot::Commands::Hi
16
18
  expect(built_in_command_classes).to include SlackRubyBot::Commands::Default
@@ -27,7 +29,7 @@ describe SlackRubyBot::Hooks::Message do
27
29
  SlackRubyBot::Config.allow_message_loops = true
28
30
  end
29
31
  it do
30
- expect(server.send(:message_to_self_not_allowed?)).to be false
32
+ expect(message_hook.send(:message_to_self_not_allowed?)).to be false
31
33
  end
32
34
  after do
33
35
  SlackRubyBot::Config.reset!
@@ -38,7 +40,7 @@ describe SlackRubyBot::Hooks::Message do
38
40
  SlackRubyBot::Config.allow_message_loops = false
39
41
  end
40
42
  it do
41
- expect(server.send(:message_to_self_not_allowed?)).to be true
43
+ expect(message_hook.send(:message_to_self_not_allowed?)).to be true
42
44
  end
43
45
  after do
44
46
  SlackRubyBot::Config.reset!
@@ -49,12 +51,12 @@ describe SlackRubyBot::Hooks::Message do
49
51
  let(:client) { Hashie::Mash.new(self: { 'id' => 'U0K8CKKT1' }) }
50
52
  context 'with message to self' do
51
53
  it do
52
- expect(server.send(:message_to_self?, client, Hashie::Mash.new(user: 'U0K8CKKT1'))).to be true
54
+ expect(message_hook.send(:message_to_self?, client, Hashie::Mash.new(user: 'U0K8CKKT1'))).to be true
53
55
  end
54
56
  end
55
57
  context 'with message to another user' do
56
58
  it do
57
- expect(server.send(:message_to_self?, client, Hashie::Mash.new(user: 'U0K8CKKT2'))).to be false
59
+ expect(message_hook.send(:message_to_self?, client, Hashie::Mash.new(user: 'U0K8CKKT2'))).to be false
58
60
  end
59
61
  end
60
62
  end
@@ -62,7 +64,7 @@ describe SlackRubyBot::Hooks::Message do
62
64
  let(:client) { Hashie::Mash.new(self: { 'id' => 'U0K8CKKT1' }) }
63
65
  it 'invokes a command' do
64
66
  expect(SlackRubyBot::Commands::Unknown).to receive(:invoke)
65
- server.message(client, Hashie::Mash.new(user: 'U0K8CKKT2'))
67
+ message_hook.call(client, Hashie::Mash.new(user: 'U0K8CKKT2'))
66
68
  end
67
69
  end
68
70
  end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe SlackRubyBot::Hooks::Set do
4
+ let(:client) { Slack::RealTime::Client.new }
5
+
6
+ context 'adding hooks' do
7
+ subject { described_class.new(client) }
8
+
9
+ it 'lets you add hook handlers' do
10
+ handler = ->(_, _) {}
11
+
12
+ expect do
13
+ subject.add(:message, handler)
14
+ end.to change(subject, :handlers)
15
+
16
+ expect(subject.handlers).to have_key(:message)
17
+ expect(subject.handlers[:message]).to eq [handler]
18
+ end
19
+
20
+ it 'lets you add multiple handlers for the same hook' do
21
+ handler_1 = ->(_, _) {}
22
+ handler_2 = ->(_, _) {}
23
+
24
+ expect do
25
+ subject.add(:message, handler_1)
26
+ subject.add(:message, handler_2)
27
+ end.to change(subject, :handlers)
28
+
29
+ expect(subject.handlers).to have_key(:message)
30
+ expect(subject.handlers[:message]).to eq [handler_1, handler_2]
31
+ end
32
+ end
33
+
34
+ context 'Slack Client injection' do
35
+ subject { described_class.new }
36
+
37
+ it "doesn't barf when add callbacks prior to injecting client" do
38
+ expect do
39
+ subject.add(:hook, ->(_, _) {})
40
+ end.to_not raise_error
41
+ end
42
+
43
+ it 'triggers hooks when client is configured later' do
44
+ handler = ->(_, _) {}
45
+
46
+ subject.add(:hook, handler)
47
+
48
+ expect(subject).to receive(:flush_handlers).once.and_call_original
49
+ expect(handler).to receive(:call).once
50
+
51
+ subject.client = client
52
+
53
+ client.send(:callback, { data: 1 }, :hook) # Abusing the callback method 100% :D
54
+ end
55
+ end
56
+ end
@@ -6,7 +6,7 @@ describe RSpec do
6
6
  command 'raise'
7
7
 
8
8
  def self.call(_client, _data, match)
9
- fail ArgumentError, match[:command]
9
+ raise ArgumentError, match[:command]
10
10
  end
11
11
  end
12
12
  end
@@ -31,12 +31,12 @@ describe SlackRubyBot::Server do
31
31
  expect(subject.send(:client).send_gifs?).to be true
32
32
  end
33
33
  it 'creates a client with a token' do
34
- expect(client).to receive(:start!) { fail 'expected' }
34
+ expect(client).to receive(:start!) { raise 'expected' }
35
35
  expect(Slack::RealTime::Client).to receive(:new).with(token: 'token', send_gifs: true, aliases: %w(foo bar)).and_return(client)
36
36
  expect { subject.start! }.to raise_error RuntimeError, 'expected'
37
37
  end
38
38
  it 'asynchronously creates a client with a token' do
39
- expect(client).to receive(:start_async) { fail 'expected' }
39
+ expect(client).to receive(:start_async) { raise 'expected' }
40
40
  expect(Slack::RealTime::Client).to receive(:new).with(token: 'token', send_gifs: true, aliases: %w(foo bar)).and_return(client)
41
41
  expect { subject.start_async }.to raise_error RuntimeError, 'expected'
42
42
  end
@@ -61,9 +61,9 @@ describe SlackRubyBot::Server do
61
61
  end.to raise_error Slack::Web::Api::Error, 'unknown'
62
62
  end
63
63
  [Faraday::Error::ConnectionFailed, Faraday::Error::TimeoutError, Faraday::Error::SSLError].each do |err|
64
- it "#{err}" do
65
- expect(client).to receive(:start!) { fail err, 'Faraday' }
66
- expect(client).to receive(:start!) { fail 'unknown' }
64
+ it err.to_s do
65
+ expect(client).to receive(:start!) { raise err, 'Faraday' }
66
+ expect(client).to receive(:start!) { raise 'unknown' }
67
67
  expect do
68
68
  subject.run
69
69
  end.to raise_error 'unknown'
@@ -1 +1,2 @@
1
1
  require 'slack-ruby-bot/rspec'
2
+ require 'webmock/rspec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-06 00:00:00.000000000 Z
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.6.0
41
- - !ruby/object:Gem::Dependency
42
- name: faye-websocket
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: activesupport
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +142,14 @@ dependencies:
156
142
  requirements:
157
143
  - - '='
158
144
  - !ruby/object:Gem::Version
159
- version: 0.32.1
145
+ version: 0.38.0
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - '='
165
151
  - !ruby/object:Gem::Version
166
- version: 0.32.1
152
+ version: 0.38.0
167
153
  description:
168
154
  email: dblock@dblock.org
169
155
  executables: []
@@ -211,9 +197,10 @@ files:
211
197
  - lib/slack-ruby-bot/commands/unknown.rb
212
198
  - lib/slack-ruby-bot/config.rb
213
199
  - lib/slack-ruby-bot/hooks.rb
214
- - lib/slack-ruby-bot/hooks/base.rb
215
200
  - lib/slack-ruby-bot/hooks/hello.rb
201
+ - lib/slack-ruby-bot/hooks/hook_support.rb
216
202
  - lib/slack-ruby-bot/hooks/message.rb
203
+ - lib/slack-ruby-bot/hooks/set.rb
217
204
  - lib/slack-ruby-bot/rspec.rb
218
205
  - lib/slack-ruby-bot/rspec/support/fixtures/slack/migration_in_progress.yml
219
206
  - lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb
@@ -261,7 +248,9 @@ files:
261
248
  - spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb
262
249
  - spec/slack-ruby-bot/commands/unknown_spec.rb
263
250
  - spec/slack-ruby-bot/config_spec.rb
251
+ - spec/slack-ruby-bot/hooks/hook_support_spec.rb
264
252
  - spec/slack-ruby-bot/hooks/message_spec.rb
253
+ - spec/slack-ruby-bot/hooks/set_spec.rb
265
254
  - spec/slack-ruby-bot/rspec/respond_with_error_spec.rb
266
255
  - spec/slack-ruby-bot/server_spec.rb
267
256
  - spec/slack-ruby-bot/support/loggable_spec.rb
@@ -287,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
276
  version: 1.3.6
288
277
  requirements: []
289
278
  rubyforge_project:
290
- rubygems_version: 2.4.8
279
+ rubygems_version: 2.5.1
291
280
  signing_key:
292
281
  specification_version: 4
293
282
  summary: The easiest way to write a Slack bot in Ruby.
@@ -319,7 +308,9 @@ test_files:
319
308
  - spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb
320
309
  - spec/slack-ruby-bot/commands/unknown_spec.rb
321
310
  - spec/slack-ruby-bot/config_spec.rb
311
+ - spec/slack-ruby-bot/hooks/hook_support_spec.rb
322
312
  - spec/slack-ruby-bot/hooks/message_spec.rb
313
+ - spec/slack-ruby-bot/hooks/set_spec.rb
323
314
  - spec/slack-ruby-bot/rspec/respond_with_error_spec.rb
324
315
  - spec/slack-ruby-bot/server_spec.rb
325
316
  - spec/slack-ruby-bot/support/loggable_spec.rb
@@ -1,10 +0,0 @@
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