Sha256: aa17ea015ad606f20dc86960635e9a0c737a4dd9ffbaa1c59de572692a9eb466

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

RSpec.describe Slack::Web::Api::Mixins::Channels do
  subject(:channels) do
    klass.new
  end

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

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

  context '#channels_id' do
    it 'leaves channels specified by ID alone' do
      expect(channels.channels_id(channel: 'C123456')).to(
        eq('ok' => true, 'channel' => { 'id' => 'C123456' })
      )
    end
    it 'translates a channel that starts with a #' do
      expect(channels.channels_id(channel: '#general')).to(
        eq('ok' => true, 'channel' => { 'id' => 'CDEADBEEF' })
      )
    end
    it 'fails with an exception' do
      expect { channels.channels_id(channel: '#invalid') }.to(
        raise_error(Slack::Web::Api::Errors::SlackError, 'channel_not_found')
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-ruby-client-0.15.0 spec/slack/web/api/mixins/channels_spec.rb
slack-ruby-client-0.14.6 spec/slack/web/api/mixins/channels_spec.rb
slack-ruby-client-0.14.5 spec/slack/web/api/mixins/channels_spec.rb