Sha256: 7492d2f63000008d442fee312e909a74f2be7ce3ad3ff75eed4c7a6b1a515e6b

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

require_relative '../../spec_helper'

describe 'API Client' do
  let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }

  it 'must raise NotAuthorizedError on unauthorized HTTP response' do
    VCR.insert_cassette 'unauthorized'

    unauthorized_client = Rev.new('welcome', 'trololo', Rev::Api::SANDBOX_HOST)
    action = lambda { unauthorized_client.get_orders_page }
    action.must_raise Rev::NotAuthorizedError
  end

  it 'must default to the production environment' do
    rev_api = Rev.new('welcome', 'trololo')
    refute_nil rev_api
    assert_equal 'https://www.rev.com/api/v1', rev_api.instance_variable_get(:@client).class.base_uri
  end

  it 'must raise NotFoundError on NotFound HTTP response' do
    VCR.insert_cassette 'not_found_order'

    action = lambda { client.get_order('trololo') }
    action.must_raise Rev::NotFoundError
  end

  after do
    VCR.eject_cassette
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rev-api-2.5.0 spec/lib/rev/api_spec.rb