Sha256: cb7e573a45dc3584e139da1e2675febc9b17d3bb6667db0c79ac31579e3dbbe5

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

RSpec.describe Slack::Web::Api::Mixins::Groups do
  let(:klass) do
    Class.new do
      include Slack::Web::Api::Mixins::Groups
    end
  end
  subject do
    klass.new
  end
  before do
    allow(subject).to receive(:groups_list).and_return(Slack::Messages::Message.new(
                                                         'groups' => [{
                                                           'id' => 'CDEADBEEF',
                                                           'name' => 'general'
                                                         }]
    ))
  end
  context '#groups_id' do
    it 'leaves groups specified by ID alone' do
      expect(subject.groups_id(channel: 'C123456')).to eq('ok' => true, 'group' => { 'id' => 'C123456' })
    end
    it 'translates a channel that starts with a #' do
      expect(subject.groups_id(channel: '#general')).to eq('ok' => true, 'group' => { 'id' => 'CDEADBEEF' })
    end
    it 'fails with an exception' do
      expect { subject.groups_id(channel: '#invalid') }.to raise_error Slack::Web::Api::Error, 'channel_not_found'
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
slack-ruby-client-0.8.1 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.8.0 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.9 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.8 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.7 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.6 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.5 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.4 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.3 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.2 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.1 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.7.0 spec/slack/web/api/mixins/groups_spec.rb
slack-ruby-client-0.6.0 spec/slack/web/api/mixins/groups_spec.rb