Sha256: ec5d95ed4754c924ca6fab8d93d1b01f8ffee0ac2af16a1c547724e7b31efb86

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 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

7 entries across 7 versions & 1 rubygems

Version Path
slack-ruby-client-1.0.0 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
slack-ruby-client-0.17.0 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
slack-ruby-client-0.16.0 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
slack-ruby-client-0.15.1 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
slack-ruby-client-0.15.0 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
slack-ruby-client-0.14.6 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
slack-ruby-client-0.14.5 spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb