Sha256: f2e85948b158fa0bfa162ecc39712fcc9931c4e03174320d0c13d1ba4cf1cacf

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

RSpec.describe Slack::Web::Api::Endpoints::Dialog do
  let(:client) { Slack::Web::Client.new }

  context 'dialog_open' do
    it 'automatically converts dialog into JSON' do
      expect(client).to receive(:post).with(
        'dialog.open',
        {
          trigger_id: '12345.98765.abcd2358fdea',
          dialog: '[]'
        }
      )
      client.dialog_open(trigger_id: '12345.98765.abcd2358fdea', dialog: [])
    end

    context 'arguments' do
      it 'requires dialog' do
        expect { client.dialog_open(trigger_id: '123') }.to(
          raise_error(ArgumentError, /Required arguments :dialog missing/)
        )
      end
      it 'requires trigger_id' do
        expect { client.dialog_open(dialog: []) }.to(
          raise_error(ArgumentError, /Required arguments :trigger_id missing/)
        )
      end
      it 'likes both dialog and trigger_id' do
        expect(client).to(
          receive(:post).with('dialog.open', hash_including(trigger_id: '123', dialog: '[]'))
        )
        expect { client.dialog_open(dialog: [], trigger_id: '123') }.not_to raise_error
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack-ruby-client-1.1.0 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb