Sha256: 8b9e4fb03047c6826c4651a27897487ebf255c5a31fe44dab5bcdcdf0d885d3b

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

RSpec.describe Slack::Web::Api::Endpoints::Chat do
  let(:client) { Slack::Web::Client.new }
  context 'chat_postMessage' do
    it 'automatically converts attachments into JSON' do
      expect(client).to receive(:post).with(
        'chat.postMessage',
        channel: 'channel',
        text: 'text',
        attachments: '[]'
      )
      client.chat_postMessage(channel: 'channel', text: 'text', attachments: [])
    end
    context 'text and attachment arguments' do
      it 'requires text or attachments' do
        expect { client.chat_postMessage(channel: 'channel') }.to raise_error ArgumentError, /Required arguments :text or :attachments missing/
      end
      it 'only text' do
        expect(client).to receive(:post).with('chat.postMessage', hash_including(text: 'text'))
        expect { client.chat_postMessage(channel: 'channel', text: 'text') }.to_not raise_error
      end
      it 'only attachments' do
        expect(client).to receive(:post).with('chat.postMessage', hash_including(attachments: '[]'))
        expect { client.chat_postMessage(channel: 'channel', attachments: []) }.to_not raise_error
      end
      it 'both text and attachments' do
        expect(client).to receive(:post).with('chat.postMessage', hash_including(text: 'text', attachments: '[]'))
        expect { client.chat_postMessage(channel: 'channel', text: 'text', attachments: []) }.to_not raise_error
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
slack-ruby-client-bhe-0.5.5 spec/slack/web/api/endpoints/chat_spec.rb
slack-ruby-client-bhe-0.5.4 spec/slack/web/api/endpoints/chat_spec.rb
slack-ruby-client-0.7.0 spec/slack/web/api/endpoints/custom_specs/chat_spec.rb
slack-ruby-client-0.6.0 spec/slack/web/api/endpoints/custom_specs/chat_spec.rb
slack-ruby-client-0.5.4 spec/slack/web/api/endpoints/chat_spec.rb
slack-ruby-client-0.5.3 spec/slack/web/api/endpoints/chat_spec.rb
slack-ruby-client-0.5.2 spec/slack/web/api/endpoints/chat_spec.rb
slack-ruby-client-0.5.1 spec/slack/web/api/endpoints/chat_spec.rb
slack-ruby-client-0.5.0 spec/slack/web/api/endpoints/chat_spec.rb
slack-ruby-client-0.4.0 spec/slack/web/api/endpoints/chat_spec.rb