Sha256: af817aa9103cffa8196dc10c59f26cde4a8fc090cd8e1907e7a94bb8cfab6fbe

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

RSpec.describe RDStation::ErrorHandler::InvalidRefreshToken do
  describe '#raise_error' do
    subject(:invalid_refresh_token) { described_class.new(errors) }

    context 'when the refresh token is invalid or was revoked' do
      let(:errors) do
        [
          {
            'error_type' => 'INVALID_REFRESH_TOKEN',
            'error_message' => 'Error Message',
          }
        ]
      end

      it 'raises an InvalidRefreshToken error' do
        expect do
          invalid_refresh_token.raise_error
        end.to raise_error(RDStation::Error::InvalidRefreshToken, 'Error Message')
      end
    end

    context 'when none of the errors are invalid refresh token errors' do
      let(:errors) do
        [
          {
            'error_message' => 'Error Message',
            'error_type' => 'RANDOM_ERROR_TYPE'
          },
          {
            'error_message' => 'Another Error Message',
            'error_type' => 'ANOTHER_RANDOM_ERROR_TYPE'
          }
        ]
      end

      it 'does not raise an InvalidRefreshToken error' do
        result = invalid_refresh_token.raise_error
        expect(result).to be_nil
      end
    end

    context 'when there are no errors' do
      let(:errors) { [] }

      it 'does not raise an InvalidRefreshToken error' do
        result = invalid_refresh_token.raise_error
        expect(result).to be_nil
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rdstation-ruby-client-2.9.0 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.8.2 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.8.1 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.8.0 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.7.0 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.6.0 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.5.3 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.5.2 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.5.1 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
rdstation-ruby-client-2.5.0 spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb