slack-ruby-client 0.15.0 → 0.15.1

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.
@@ -166,6 +166,23 @@ RSpec.describe Slack::RealTime::Client do # rubocop:disable Metrics/BlockLength
166
166
  expect(client.store.team.name).to eq 'New Team Name Inc.'
167
167
  end
168
168
  end
169
+
170
+ describe '#run_handlers' do
171
+ describe 'empty events' do
172
+ before do
173
+ @e = client.store.class.events
174
+ client.store.class.events = nil
175
+ end
176
+
177
+ after do
178
+ client.store.class.events = @e
179
+ end
180
+
181
+ it 'returns false when event is nil' do
182
+ expect(client.send(:run_handlers, 'example', {})).to be nil
183
+ end
184
+ end
185
+ end
169
186
  end
170
187
 
171
188
  describe '#start_async' do
@@ -13,7 +13,7 @@ RSpec.describe Slack::Web::Api::Mixins::Channels do
13
13
  end
14
14
 
15
15
  before do
16
- allow(channels).to receive(:channels_list).and_return(
16
+ allow(channels).to receive(:channels_list).and_yield(
17
17
  Slack::Messages::Message.new(
18
18
  'channels' => [{
19
19
  'id' => 'CDEADBEEF',
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Slack::Web::Client do
5
+ context 'conversations_setTopic' do
6
+ it 'does not invoke conversations_list', vcr: { cassette_name: 'web/conversations_setTopic' } do
7
+ rc = subject.conversations_setTopic({ channel: 'C018Y6VH39D', topic: 'new topic' })
8
+ expect(rc.channel.topic.value).to eq 'new topic'
9
+ end
10
+
11
+ it 'resolves IDs via conversations_list', vcr: { cassette_name: 'web/conversations_setTopic_one_page' } do
12
+ rc = subject.conversations_setTopic({ channel: '#1', topic: 'new topic' })
13
+ expect(rc.channel.topic.value).to eq 'new topic'
14
+ end
15
+
16
+ it 'paginates to resolve IDs', vcr: { cassette_name: 'web/conversations_setTopic_paginated' } do
17
+ rc = subject.conversations_setTopic({ channel: '#topic', topic: 'new topic' })
18
+ expect(rc.channel.topic.value).to eq 'new topic'
19
+ end
20
+ end
21
+ end
@@ -9,18 +9,20 @@ RSpec.describe Slack::Web::Api::Mixins::Conversations do
9
9
  let(:klass) do
10
10
  Class.new do
11
11
  include Slack::Web::Api::Mixins::Conversations
12
-
13
- def conversations_list
14
- Slack::Messages::Message.new(
15
- 'channels' => [{
16
- 'id' => 'CDEADBEEF',
17
- 'name' => 'general'
18
- }]
19
- )
20
- end
21
12
  end
22
13
  end
23
14
 
15
+ before do
16
+ allow(conversations).to receive(:conversations_list).and_yield(
17
+ Slack::Messages::Message.new(
18
+ 'channels' => [{
19
+ 'id' => 'CDEADBEEF',
20
+ 'name' => 'general'
21
+ }]
22
+ )
23
+ )
24
+ end
25
+
24
26
  describe '#conversations_id' do
25
27
  it 'leaves channels specified by ID alone' do
26
28
  expect(conversations.conversations_id(channel: 'C123456')).to(
@@ -13,7 +13,7 @@ RSpec.describe Slack::Web::Api::Mixins::Groups do
13
13
  end
14
14
 
15
15
  before do
16
- allow(groups).to receive(:groups_list).and_return(
16
+ allow(groups).to receive(:groups_list).and_yield(
17
17
  Slack::Messages::Message.new(
18
18
  'groups' => [{
19
19
  'id' => 'CDEADBEEF',
@@ -13,7 +13,7 @@ RSpec.describe Slack::Web::Api::Mixins::Users do
13
13
  end
14
14
 
15
15
  before do
16
- allow(users).to receive(:users_list).and_return(
16
+ allow(users).to receive(:users_list).and_yield(
17
17
  Slack::Messages::Message.new(
18
18
  'members' => [{
19
19
  'id' => 'UDEADBEEF',
@@ -150,6 +150,50 @@ RSpec.describe Slack::Web::Client do
150
150
  end
151
151
  end
152
152
 
153
+ context 'adapter option' do
154
+ let(:adapter) { Faraday.default_adapter }
155
+ let(:adapter_class) { Faraday::Adapter::NetHttp }
156
+
157
+ around do |ex|
158
+ previous_adapter = Faraday.default_adapter
159
+ # ensure default adapter is set for this spec
160
+ Faraday.default_adapter = :net_http
161
+ ex.run
162
+ Faraday.default_adapter = previous_adapter
163
+ end
164
+
165
+ context 'default adapter' do
166
+ describe '#initialize' do
167
+ it 'sets adapter' do
168
+ expect(client.adapter).to eq adapter
169
+ end
170
+ it 'creates a connection with an adapter' do
171
+ expect(client.send(:connection).adapter).to eq adapter_class
172
+ end
173
+ end
174
+ end
175
+
176
+ context 'non default adapter' do
177
+ let(:adapter) { :typhoeus }
178
+ let(:adapter_class) { Faraday::Adapter::Typhoeus }
179
+
180
+ before do
181
+ described_class.configure do |config|
182
+ config.adapter = adapter
183
+ end
184
+ end
185
+
186
+ describe '#initialize' do
187
+ it 'sets adapter' do
188
+ expect(client.adapter).to eq adapter
189
+ end
190
+ it 'creates a connection with an adapter' do
191
+ expect(client.send(:connection).adapter).to eq adapter_class
192
+ end
193
+ end
194
+ end
195
+ end
196
+
153
197
  context 'timeout options' do
154
198
  before do
155
199
  described_class.configure do |config|
@@ -7,4 +7,8 @@ VCR.configure do |config|
7
7
  config.hook_into :webmock
8
8
  # config.default_cassette_options = { record: :new_episodes }
9
9
  config.configure_rspec_metadata!
10
+ config.before_record do |i|
11
+ i.request.body.gsub!(ENV['SLACK_API_TOKEN'], 'token') if ENV.key?('SLACK_API_TOKEN')
12
+ i.response.body.force_encoding('UTF-8')
13
+ end
10
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-26 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -479,6 +479,9 @@ files:
479
479
  - spec/fixtures/slack/web/auth_test_error.yml
480
480
  - spec/fixtures/slack/web/auth_test_success.yml
481
481
  - spec/fixtures/slack/web/channels_info.yml
482
+ - spec/fixtures/slack/web/conversations_setTopic.yml
483
+ - spec/fixtures/slack/web/conversations_setTopic_one_page.yml
484
+ - spec/fixtures/slack/web/conversations_setTopic_paginated.yml
482
485
  - spec/fixtures/slack/web/groups_info.yml
483
486
  - spec/fixtures/slack/web/paginated_users_list.yml
484
487
  - spec/fixtures/slack/web/rtm_connect.yml
@@ -574,6 +577,7 @@ files:
574
577
  - spec/slack/web/api/errors/service_unavailable_spec.rb
575
578
  - spec/slack/web/api/errors/slack_error_spec.rb
576
579
  - spec/slack/web/api/mixins/channels_spec.rb
580
+ - spec/slack/web/api/mixins/conversations_list_spec.rb
577
581
  - spec/slack/web/api/mixins/conversations_spec.rb
578
582
  - spec/slack/web/api/mixins/groups_spec.rb
579
583
  - spec/slack/web/api/mixins/users_spec.rb
@@ -606,7 +610,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
606
610
  - !ruby/object:Gem::Version
607
611
  version: 1.3.6
608
612
  requirements: []
609
- rubygems_version: 3.1.2
613
+ rubygems_version: 3.1.3
610
614
  signing_key:
611
615
  specification_version: 4
612
616
  summary: Slack Web and RealTime API client.
@@ -616,6 +620,9 @@ test_files:
616
620
  - spec/fixtures/slack/web/auth_test_error.yml
617
621
  - spec/fixtures/slack/web/auth_test_success.yml
618
622
  - spec/fixtures/slack/web/channels_info.yml
623
+ - spec/fixtures/slack/web/conversations_setTopic.yml
624
+ - spec/fixtures/slack/web/conversations_setTopic_one_page.yml
625
+ - spec/fixtures/slack/web/conversations_setTopic_paginated.yml
619
626
  - spec/fixtures/slack/web/groups_info.yml
620
627
  - spec/fixtures/slack/web/paginated_users_list.yml
621
628
  - spec/fixtures/slack/web/rtm_connect.yml
@@ -711,6 +718,7 @@ test_files:
711
718
  - spec/slack/web/api/errors/service_unavailable_spec.rb
712
719
  - spec/slack/web/api/errors/slack_error_spec.rb
713
720
  - spec/slack/web/api/mixins/channels_spec.rb
721
+ - spec/slack/web/api/mixins/conversations_list_spec.rb
714
722
  - spec/slack/web/api/mixins/conversations_spec.rb
715
723
  - spec/slack/web/api/mixins/groups_spec.rb
716
724
  - spec/slack/web/api/mixins/users_spec.rb