Sha256: 193130c65cac9a1ebc0ee205d14391d7a03a34d53d3cf5a60b8c5cf78e061cd6

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

RSpec.describe Slack::Web::Api::Mixins::Conversations do
  subject(:conversations) do
    klass.new
  end

  let(:klass) do
    Class.new do
      include Slack::Web::Api::Mixins::Conversations
    end
  end

  before do
    allow(conversations).to receive(:conversations_list).and_yield(
      Slack::Messages::Message.new(
        'channels' => [{
          'id' => 'CDEADBEEF',
          'name' => 'general'
        }]
      )
    )
  end

  describe '#conversations_id' do
    it 'leaves channels specified by ID alone' do
      expect(conversations.conversations_id(channel: 'C123456')).to(
        eq('ok' => true, 'channel' => { 'id' => 'C123456' })
      )
    end

    it 'translates a channel that starts with a #' do
      expect(conversations.conversations_id(channel: '#general')).to(
        eq('ok' => true, 'channel' => { 'id' => 'CDEADBEEF' })
      )
    end

    it 'fails with an exception' do
      expect { conversations.conversations_id(channel: '#invalid') }.to(
        raise_error(Slack::Web::Api::Errors::SlackError, 'channel_not_found')
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-client-2.4.0 spec/slack/web/api/mixins/conversations_spec.rb
slack-ruby-client-2.3.0 spec/slack/web/api/mixins/conversations_spec.rb
slack-ruby-client-2.2.0 spec/slack/web/api/mixins/conversations_spec.rb
slack-ruby-client-2.1.0 spec/slack/web/api/mixins/conversations_spec.rb
slack-ruby-client-2.0.0 spec/slack/web/api/mixins/conversations_spec.rb