Sha256: c35b37ad28f347f947f2eaaff21e9e8dc3bcce82be5feaef52c5235e2064e270

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

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

  it 'provides access to the response object', vcr: { cassette_name: 'web/auth_test_error' } do
    begin
      client.auth_test
      raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
    rescue described_class => e
      expect(e.response).not_to be_nil
      expect(e.response.status).to eq 200
      expect(e.message).to eql 'not_authed'
      expect(e.error).to eql 'not_authed'
      expect(e.response_metadata).to be_nil
    end
  end

  it 'provides access to any response_metadata', vcr: { cassette_name: 'web/views_open_error' } do
    begin
      client.views_open(trigger_id: 'trigger_id', view: {})
      raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
    rescue described_class => e
      expect(e.response).not_to be_nil
      expect(e.response.status).to eq 200
      expect(e.message).to eql 'invalid_arguments'
      expect(e.error).to eql 'invalid_arguments'
      expect(e.response_metadata).to eq(
        'messages' => [
          "[ERROR] missing required field: title [json-pointer:\/view]",
          "[ERROR] missing required field: blocks [json-pointer:\/view]",
          "[ERROR] missing required field: type [json-pointer:\/view]"
        ]
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-client-0.17.0 spec/slack/web/api/errors/slack_error_spec.rb
slack-ruby-client-0.16.0 spec/slack/web/api/errors/slack_error_spec.rb
slack-ruby-client-0.15.1 spec/slack/web/api/errors/slack_error_spec.rb
slack-ruby-client-0.15.0 spec/slack/web/api/errors/slack_error_spec.rb
slack-ruby-client-0.14.6 spec/slack/web/api/errors/slack_error_spec.rb