slack-ruby-bot 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88982b31e113e853ff4c707a7718f0739ccf260e
4
- data.tar.gz: 9f818712b6659e1281a89b0a144b922f9b66e61d
3
+ metadata.gz: 12c173de864218ce41d7115da1a9c6ded20649eb
4
+ data.tar.gz: 01733d1afa189753bd3bc338a9508f138a69dbcb
5
5
  SHA512:
6
- metadata.gz: 537ee07e13e6500c453b71cbfffa1b9eeda032baaf86319af4c298a6e65b3adc51de771694e6cc5107e4858d3344633bfaca7b70f23025afc6c5a1eb8bb23580
7
- data.tar.gz: 6e2f758c616871af780b376613ef9eac7c0bfe6438f65e5950b035e4e450da31d207674b558b9e3726ca3287f0e468adda333988fa3c2a53b7fe0ac50757b660
6
+ metadata.gz: e834c192faaa6922e02c536c6fb8620fe20d32bcb58be48dea83c9f6283b75c6cbe738e2422ee67830f928d10979fbdd03cc87a8946cc565501c839c7d659dba
7
+ data.tar.gz: da3d808d4863af50cc8cdfc689ead159d013fc4955428d6c1e6cc6069417817112a870da7a1a8e420de283da4579c219569178848f4f3c05d64aa20abbc03bdc
@@ -1,40 +1,56 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-09-24 09:10:21 -0400 using RuboCop version 0.38.0.
3
+ # on 2017-06-16 13:07:42 -0500 using RuboCop version 0.48.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 4
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: Include, TreatCommentsAsGroupSeparators.
12
+ # Include: **/Gemfile, **/gems.rb
13
+ Bundler/OrderedGems:
14
+ Exclude:
15
+ - 'examples/inventory/Gemfile'
16
+ - 'examples/market/Gemfile'
17
+ - 'examples/minimal/Gemfile'
18
+ - 'examples/weather/Gemfile'
19
+
9
20
  # Offense count: 1
10
21
  Lint/HandleExceptions:
11
22
  Exclude:
12
23
  - 'lib/initializers/giphy.rb'
13
24
 
14
- # Offense count: 5
25
+ # Offense count: 6
15
26
  Metrics/AbcSize:
16
27
  Max: 36
17
28
 
29
+ # Offense count: 21
30
+ # Configuration parameters: CountComments, ExcludedMethods.
31
+ Metrics/BlockLength:
32
+ Max: 120
33
+
18
34
  # Offense count: 2
19
35
  Metrics/CyclomaticComplexity:
20
- Max: 11
36
+ Max: 13
21
37
 
22
- # Offense count: 156
23
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
38
+ # Offense count: 199
39
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
24
40
  # URISchemes: http, https
25
41
  Metrics/LineLength:
26
42
  Max: 147
27
43
 
28
- # Offense count: 6
44
+ # Offense count: 10
29
45
  # Configuration parameters: CountComments.
30
46
  Metrics/MethodLength:
31
47
  Max: 27
32
48
 
33
49
  # Offense count: 2
34
50
  Metrics/PerceivedComplexity:
35
- Max: 11
51
+ Max: 13
36
52
 
37
- # Offense count: 26
53
+ # Offense count: 30
38
54
  Style/Documentation:
39
55
  Enabled: false
40
56
 
@@ -43,13 +59,58 @@ Style/DoubleNegation:
43
59
  Exclude:
44
60
  - 'lib/slack-ruby-bot/commands/base.rb'
45
61
 
46
- # Offense count: 1
47
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
62
+ # Offense count: 2
63
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
64
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
48
65
  Style/FileName:
49
66
  Exclude:
67
+ - 'Dangerfile'
50
68
  - 'lib/slack-ruby-bot.rb'
51
69
 
70
+ # Offense count: 2
71
+ # Cop supports --auto-correct.
72
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
73
+ # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
74
+ Style/IndentHeredoc:
75
+ Exclude:
76
+ - 'lib/slack-ruby-bot/commands/help.rb'
77
+ - 'spec/slack-ruby-bot/commands/help_spec.rb'
78
+
52
79
  # Offense count: 1
80
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
81
+ # SupportedStyles: module_function, extend_self
53
82
  Style/ModuleFunction:
54
83
  Exclude:
55
84
  - 'lib/slack-ruby-bot/config.rb'
85
+
86
+ # Offense count: 3
87
+ # Cop supports --auto-correct.
88
+ Style/MultilineIfModifier:
89
+ Exclude:
90
+ - 'lib/slack-ruby-bot/app.rb'
91
+ - 'lib/slack-ruby-bot/client.rb'
92
+ - 'lib/slack-ruby-bot/commands/base.rb'
93
+
94
+ # Offense count: 5
95
+ # Cop supports --auto-correct.
96
+ # Configuration parameters: PreferredDelimiters.
97
+ Style/PercentLiteralDelimiters:
98
+ Exclude:
99
+ - 'lib/slack-ruby-bot/server.rb'
100
+ - 'spec/slack-ruby-bot/commands/aliases_spec.rb'
101
+ - 'spec/slack-ruby-bot/hooks/hook_support_spec.rb'
102
+ - 'spec/slack-ruby-bot/server_spec.rb'
103
+
104
+ # Offense count: 3
105
+ # Cop supports --auto-correct.
106
+ # Configuration parameters: SupportedStyles.
107
+ # SupportedStyles: percent, brackets
108
+ Style/SymbolArray:
109
+ EnforcedStyle: brackets
110
+
111
+ # Offense count: 2
112
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
113
+ # SupportedStyles: snake_case, normalcase, non_integer
114
+ Style/VariableNumber:
115
+ Exclude:
116
+ - 'spec/slack-ruby-bot/hooks/set_spec.rb'
@@ -1,3 +1,9 @@
1
+ ### 0.10.4 (07/05/2017)
2
+
3
+ * [#149](https://github.com/slack-ruby/slack-ruby-bot/pull/149): Add `logger` configuration to set a custom logger - [@upscent](https://github.com/upscent).
4
+ * [#147](https://github.com/slack-ruby/slack-ruby-bot/pull/147): Adds `server.on` as a shortcut for `hooks.add` and deprecate `hooks` method - [@laertispappas](https://github.com/laertispappas).
5
+ * [#143](https://github.com/slack-ruby/slack-ruby-bot/pull/143): Provide `permitted?` method to allow for simple authorization extensions - [@chuckremes](https://github.com/chuckremes).
6
+
1
7
  ### 0.10.3 (06/15/2017)
2
8
 
3
9
  * [#145](https://github.com/slack-ruby/slack-ruby-bot/pull/145): Map multiple command strings to same controller method - [@chuckremes](https://github.com/chuckremes).
data/README.md CHANGED
@@ -212,6 +212,25 @@ class Phone < SlackRubyBot::Commands::Base
212
212
  end
213
213
  ```
214
214
 
215
+ ### Authorization
216
+
217
+ The framework does not provide any user authentication or command authorization capability out of the box. However, the `SlackRubyBot::Commands::Base` class does check every command invocation for permission prior to executing the command. The default method always returns true.
218
+
219
+ Therefore, subclasses of `SlackRubyBot::Commands::Base` can override the `permitted?` private method to provide its own authorization logic. This method is intended to be exploited by user code or external gems that want to provide custom authorization logic for command execution.
220
+
221
+ ```ruby
222
+ class AuthorizedBot < SlackRubyBot::Commands::Base
223
+ command 'phone home' do |client, data, match|
224
+ client.say(channel: data.channel, text: 'Elliot!')
225
+ end
226
+
227
+ # Only allow user 'Uxyzabc' to run this command
228
+ def self.permitted?(client, data, match)
229
+ data && data.user && data.user == 'Uxyzabc'
230
+ end
231
+ end
232
+ ```
233
+
215
234
  ### Animated GIFs
216
235
 
217
236
  The `SlackRubyBot::Client` implementation comes with GIF support.
@@ -261,22 +280,37 @@ Hooks are event handlers and respond to Slack RTM API [events](https://api.slack
261
280
 
262
281
  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.
263
282
 
264
- Hooks are registered onto the `SlackRubyBot::Server` instance, by way of a configuration hash
283
+ Hooks can be registered using different methods based on user preference / use case.
284
+ Currently someone can use one of the following methods:
285
+
286
+ * Pass `hooks` in `SlackRubyBot::Server` initialization.
287
+ * Register `hooks` on `SlackRubyBot::Server` using `on` class method.
288
+ * Register `hooks` on `SlackRubyBot::Server` using `on` instance method.
289
+
290
+
291
+ ##### Hooks registration on `SlackRubyBot::Server` initialization
265
292
 
266
293
  ```ruby
267
294
  SlackRubyBot::Server.new(hook_handlers: {
268
- hello: MyBot::Hooks::UserChange.new
295
+ hello: MyBot::Hooks::UserChange.new,
296
+ user_change: [->(client, data) { }, ->(client, data) {}]
269
297
  })
270
298
  ```
271
299
 
272
- or at any time by pushing it to the `HookSet`
300
+ ##### Hooks registration on a `SlackRubyBot::Server` instance
273
301
 
274
302
  ```ruby
275
- # Push an object that implements the
276
- server.hooks.add(:hello, MyBot::Hooks::UserChange.new)
303
+ # Register an object that implements `call` method
304
+ class MyBot::Hooks::Hello
305
+ def call(client, data)
306
+ puts "Hello"
307
+ end
308
+ end
277
309
 
278
- # Push a lambda to handle the event
279
- server.hooks.add(:hello, ->(client, data) { puts "Hello!" })
310
+ server.on(:hello, MyBot::Hooks::Hello.new)
311
+
312
+ # or register a lambda function to handle the event
313
+ server.on(:hello, ->(client, data) { puts "Hello!" })
280
314
  ```
281
315
 
282
316
  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.
@@ -288,14 +322,16 @@ module MyBot
288
322
  def call(client, data)
289
323
  # data['user']['id'] contains the user ID
290
324
  # data['user']['name'] contains the new user name
291
- ...
325
+ # ...
292
326
  end
293
327
  end
294
328
  end
295
329
  end
296
330
  ```
297
331
 
298
- Hooks can also be written as blocks inside the `SlackRubyBot::Server` class, for example
332
+ ##### Hooks registration on `SlackRubyBot::Server` class
333
+
334
+ Example:
299
335
 
300
336
  ```ruby
301
337
  module MyBot
@@ -304,6 +340,11 @@ module MyBot
304
340
  # data['user']['id'] contains the user ID
305
341
  # data['user']['name'] contains the new user name
306
342
  end
343
+
344
+ on 'user_change', ->(client, data) {
345
+ # data['user']['id'] contains the user ID
346
+ # data['user']['name'] contains the new user name
347
+ }
307
348
  end
308
349
  end
309
350
  ```
@@ -312,6 +353,19 @@ These will get pushed into the hook set on initialization.
312
353
 
313
354
  Either by configuration, explicit assignment or hook blocks, multiple handlers can exist for the same event type.
314
355
 
356
+
357
+ #### Deprecated hook registration
358
+
359
+ Registering a hook method using `hooks.add` is considered deprecated and
360
+ will be removed on future versions.
361
+
362
+ ```ruby
363
+ # [DEPRECATED]
364
+ server.hooks.add(:hello, MyBot::Hooks::UserChange.new)
365
+ server.hooks.add(:hello, ->(client, data) { puts "Hello!" })
366
+
367
+ ```
368
+
315
369
  ### Message Loop Protection
316
370
 
317
371
  By default bots do not respond to their own messages. If you wish to change that behavior, set `allow_message_loops` to `true`.
@@ -324,12 +378,22 @@ end
324
378
 
325
379
  ### Logging
326
380
 
327
- 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.
381
+ By default bots set a logger to `$stdout` with `DEBUG` level. The logger is used in both the RealTime and Web clients.
382
+
383
+ Silence logger as follows.
328
384
 
329
385
  ```ruby
330
386
  SlackRubyBot::Client.logger.level = Logger::WARN
331
387
  ```
332
388
 
389
+ If you wish to customize logger, set `logger` to your logger.
390
+
391
+ ```ruby
392
+ SlackRubyBot.configure do |config|
393
+ config.logger = Logger.new("slack-ruby-bot.log", "daily")
394
+ end
395
+ ```
396
+
333
397
  ### Advanced Integration
334
398
 
335
399
  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,25 @@
1
1
  Upgrading SlackRubyBot
2
2
  ======================
3
3
 
4
+ ### Upgrading to >= 0.10.4
5
+
6
+ #### Replace `server.hooks.add` with `server.on`
7
+
8
+ We have deprecated `SlackRubyBot::Server#hooks` in favor of `SlackRubyBot::Server#on` instance method. All users using `SlackRubyBot::Server#hooks` method should
9
+ change their codebase and use the new method instead. Method signature is not affected.
10
+
11
+ Example:
12
+
13
+ ```ruby
14
+ # Given server is an instance of SlackRubyBot::Server
15
+ #
16
+ # Before
17
+ server.hooks.add :hello, Greet.new
18
+
19
+ # After
20
+ server.on :hello, Greet.new
21
+ ```
22
+
4
23
  ### Upgrading to >= 0.9.0
5
24
 
6
25
  #### Add giphy to your Gemfile for GIF support
@@ -68,9 +68,9 @@ module SlackRubyBot
68
68
  called = true
69
69
  call = options[:call]
70
70
  if call
71
- call.call(client, data, match)
71
+ call.call(client, data, match) if permitted?(client, data, match)
72
72
  elsif respond_to?(:call)
73
- send(:call, client, data, match)
73
+ send(:call, client, data, match) if permitted?(client, data, match)
74
74
  else
75
75
  raise NotImplementedError, data.text
76
76
  end
@@ -115,6 +115,12 @@ module SlackRubyBot
115
115
  return if routes && routes.any?
116
116
  command default_command_name
117
117
  end
118
+
119
+ # Intended to be overridden by subclasses to hook in an
120
+ # authorization mechanism.
121
+ def permitted?(_client, _data, _match)
122
+ true
123
+ end
118
124
  end
119
125
  end
120
126
  end
@@ -2,7 +2,7 @@ module SlackRubyBot
2
2
  module Config
3
3
  extend self
4
4
 
5
- ATTRS = [:token, :url, :aliases, :user, :user_id, :team, :team_id, :allow_message_loops, :send_gifs].freeze
5
+ ATTRS = [:token, :url, :aliases, :user, :user_id, :team, :team_id, :allow_message_loops, :send_gifs, :logger].freeze
6
6
  attr_accessor(*ATTRS)
7
7
 
8
8
  def allow_message_loops?
@@ -18,7 +18,12 @@ module SlackRubyBot
18
18
 
19
19
  # Instance stuff
20
20
  def hooks
21
- @hooks ||= SlackRubyBot::Hooks::Set.new
21
+ warn Kernel.caller.first + ' [DEPRECATION] `hooks` method is deprecated. Please use `server.on` instead to register a hook.'
22
+ _hooks
23
+ end
24
+
25
+ def on(event_name, handler)
26
+ _hooks.add(event_name, handler)
22
27
  end
23
28
 
24
29
  def flush_hook_blocks
@@ -27,11 +32,18 @@ module SlackRubyBot
27
32
  add_hook_handlers(self.class.hook_blocks)
28
33
  end
29
34
 
35
+ # TODO: This should be deprecated in favor of `on`
30
36
  def add_hook_handlers(handler_hash)
31
37
  handler_hash.each do |hook, handlers|
32
- Array(handlers).each { |handler| hooks.add(hook, handler) }
38
+ Array(handlers).each { |handler| on(hook, handler) }
33
39
  end
34
40
  end
41
+
42
+ # Temp use this method in order to deprecate `hooks` and revisit
43
+ def _hooks
44
+ @hooks ||= SlackRubyBot::Hooks::Set.new
45
+ end
46
+ private :_hooks
35
47
  end
36
48
  end
37
49
  end
@@ -11,12 +11,10 @@ module SlackRubyBot
11
11
  end
12
12
 
13
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
14
+ handlers[hook_name] ||= ::Set.new
15
+ handlers[hook_name] << handler
16
+
17
+ register_callback(hook_name)
20
18
  end
21
19
 
22
20
  def client=(client)
@@ -0,0 +1,25 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :not_respond do
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
+ channel, user, message = parse(actual)
13
+
14
+ expect(client).not_to receive(:message)
15
+ message_command.call(client, Hashie::Mash.new(text: message, channel: channel, user: user))
16
+ true
17
+ end
18
+
19
+ private
20
+
21
+ def parse(actual)
22
+ actual = { message: actual } unless actual.is_a?(Hash)
23
+ [actual[:channel] || 'channel', actual[:user] || 'user', actual[:message]]
24
+ end
25
+ end
@@ -101,7 +101,7 @@ module SlackRubyBot
101
101
  @client = nil
102
102
  restart! unless @stopping
103
103
  end
104
- hooks.client = client
104
+ _hooks.client = client
105
105
 
106
106
  client
107
107
  end
@@ -7,9 +7,9 @@ module SlackRubyBot
7
7
 
8
8
  module ClassMethods
9
9
  def logger
10
- @logger ||= begin
10
+ @logger ||= SlackRubyBot::Config.logger || begin
11
11
  $stdout.sync = true
12
- Logger.new(STDOUT)
12
+ Logger.new($stdout)
13
13
  end
14
14
  end
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module SlackRubyBot
2
- VERSION = '0.10.3'.freeze
2
+ VERSION = '0.10.4'.freeze
3
3
  end
@@ -0,0 +1,34 @@
1
+ describe SlackRubyBot::Commands, 'permitted?' do
2
+ let! :command do
3
+ Class.new(SlackRubyBot::Commands::Base) do
4
+ class << self
5
+ attr_accessor :_flag1
6
+ attr_accessor :_flag2
7
+ def permitted?(_client, _data, match)
8
+ match[:command] == 'saylo'
9
+ end
10
+ end
11
+ @_flag1 = false
12
+ @_flag2 = false
13
+ command 'saylo' do |_client, _data, _match|
14
+ self._flag1 = true
15
+ end
16
+ command 'sayallowed' do |_client, _data, _match|
17
+ self._flag2 = true
18
+ end
19
+ end
20
+ end
21
+ def app
22
+ SlackRubyBot::App.new
23
+ end
24
+
25
+ it 'allows command when returning true' do
26
+ expect(message: "#{SlackRubyBot::Config.user} saylo").to not_respond
27
+ expect(command._flag1).to be true
28
+ end
29
+
30
+ it 'denies command when returning false' do
31
+ expect(message: "#{SlackRubyBot::Config.user} sayallowed").to not_respond
32
+ expect(command._flag2).to be false
33
+ end
34
+ end
@@ -35,11 +35,34 @@ describe SlackRubyBot::Hooks::HookSupport do
35
35
  it 'registers class hook blocks as hook handlers in set' do
36
36
  object = subject.new
37
37
 
38
- expect(object.hooks).to receive(:add).exactly(3).times.and_call_original
38
+ expect(object.send(:_hooks)).to receive(:add).exactly(3).times.and_call_original
39
39
 
40
40
  expect do
41
41
  object.flush_hook_blocks
42
- end.to change { object.hooks.handlers.size }.by(2)
42
+ end.to change { object.send(:_hooks).handlers.size }.by(2)
43
+ end
44
+ end
45
+
46
+ describe '#on' do
47
+ subject { super().new }
48
+ it 'delegates to `hooks.add` method' do
49
+ event_name = :message_received
50
+ handler = ->(_, _) {}
51
+
52
+ expect(subject.send(:_hooks)).to receive(:add).with(event_name, handler).and_call_original
53
+ subject.on(event_name, handler)
54
+ end
55
+ end
56
+
57
+ describe '#hooks' do
58
+ subject { super().new }
59
+ it { expect(subject.hooks).to eq subject.send(:_hooks) }
60
+ end
61
+
62
+ describe '#_hooks' do
63
+ it 'returns a SlackRubyBot::Hooks::Set instance' do
64
+ hooks_set = subject.new.send(:_hooks)
65
+ expect(hooks_set).to be_a SlackRubyBot::Hooks::Set
43
66
  end
44
67
  end
45
68
  end
@@ -12,7 +12,7 @@ describe SlackRubyBot::Hooks::Set do
12
12
  end.to change(subject, :handlers)
13
13
 
14
14
  expect(subject.handlers).to have_key(:message)
15
- expect(subject.handlers[:message]).to eq [handler]
15
+ expect(subject.handlers[:message]).to eq Set.new.add(handler)
16
16
  end
17
17
 
18
18
  it 'lets you add multiple handlers for the same hook' do
@@ -25,7 +25,7 @@ describe SlackRubyBot::Hooks::Set do
25
25
  end.to change(subject, :handlers)
26
26
 
27
27
  expect(subject.handlers).to have_key(:message)
28
- expect(subject.handlers[:message]).to eq [handler_1, handler_2]
28
+ expect(subject.handlers[:message]).to eq Set.new([handler_1, handler_2])
29
29
  end
30
30
  end
31
31
 
@@ -1,23 +1,23 @@
1
1
  describe SlackRubyBot::Loggable do
2
- let! :class_with_logger do
3
- Class.new(SlackRubyBot::Commands::Base) do
4
- def public_logger
5
- logger
2
+ let!(:class_with_logger) { Class.new SlackRubyBot::Commands::Base }
3
+ let!(:child_class_with_logger) { Class.new class_with_logger }
4
+ describe 'logger for class' do
5
+ context 'set logger by config' do
6
+ let(:logger) { double 'logger' }
7
+ it do
8
+ SlackRubyBot.configure do |config|
9
+ config.logger = logger
10
+ end
11
+ expect(class_with_logger.logger).to eq logger
12
+ expect(child_class_with_logger.logger).to eq logger
6
13
  end
7
14
  end
8
- end
9
- let! :child_class_with_logger do
10
- Class.new(class_with_logger) do
11
- def public_logger
12
- logger
15
+ context 'default logger' do
16
+ it do
17
+ expect(class_with_logger.logger).to be_kind_of Logger
18
+ expect(child_class_with_logger.logger).to be_kind_of Logger
13
19
  end
14
20
  end
15
- end
16
- describe 'logger for class' do
17
- it do
18
- expect(class_with_logger.logger).to be_kind_of Logger
19
- expect(child_class_with_logger.logger).to be_kind_of Logger
20
- end
21
21
  it 'should be cached' do
22
22
  first_logger = class_with_logger.logger
23
23
  second_logger = class_with_logger.logger
@@ -30,18 +30,9 @@ describe SlackRubyBot::Loggable do
30
30
  end
31
31
  end
32
32
  describe 'logger for instance' do
33
- it do
34
- expect(class_with_logger.new.public_logger).to be_kind_of Logger
35
- end
36
- it 'should be cached' do
37
- first_logger = class_with_logger.new.public_logger
38
- second_logger = class_with_logger.new.public_logger
39
- expect(first_logger.object_id).to eq second_logger.object_id
40
- end
41
- it 'should not be shared by a child class' do
42
- first_logger = class_with_logger.new.public_logger
43
- second_logger = child_class_with_logger.new.public_logger
44
- expect(first_logger.object_id).to_not eq second_logger.object_id
33
+ it 'same with one for class' do
34
+ expect(class_with_logger.new.logger.object_id).to eq class_with_logger.logger.object_id
35
+ expect(child_class_with_logger.new.logger.object_id).to eq child_class_with_logger.logger.object_id
45
36
  end
46
37
  end
47
38
  end
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.10.3
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-15 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -187,6 +187,7 @@ files:
187
187
  - lib/slack-ruby-bot/rspec/support/bots_for_tests.rb
188
188
  - lib/slack-ruby-bot/rspec/support/fixtures/slack/migration_in_progress.yml
189
189
  - lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb
190
+ - lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb
190
191
  - lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb
191
192
  - lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb
192
193
  - lib/slack-ruby-bot/rspec/support/slack_api_key.rb
@@ -213,6 +214,7 @@ files:
213
214
  - spec/slack-ruby-bot/commands/bot_message_spec.rb
214
215
  - spec/slack-ruby-bot/commands/bot_spec.rb
215
216
  - spec/slack-ruby-bot/commands/commands_command_classes_spec.rb
217
+ - spec/slack-ruby-bot/commands/commands_permitted_spec.rb
216
218
  - spec/slack-ruby-bot/commands/commands_precedence_spec.rb
217
219
  - spec/slack-ruby-bot/commands/commands_regexp_escape_spec.rb
218
220
  - spec/slack-ruby-bot/commands/commands_spaces_spec.rb
@@ -278,6 +280,7 @@ test_files:
278
280
  - spec/slack-ruby-bot/commands/bot_message_spec.rb
279
281
  - spec/slack-ruby-bot/commands/bot_spec.rb
280
282
  - spec/slack-ruby-bot/commands/commands_command_classes_spec.rb
283
+ - spec/slack-ruby-bot/commands/commands_permitted_spec.rb
281
284
  - spec/slack-ruby-bot/commands/commands_precedence_spec.rb
282
285
  - spec/slack-ruby-bot/commands/commands_regexp_escape_spec.rb
283
286
  - spec/slack-ruby-bot/commands/commands_spaces_spec.rb