Sha256: eb33c282dbacd94913935c0affbda6e4c666d626946ff2de21aa79f732a87b29

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

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

2 entries across 2 versions & 1 rubygems

Version Path
rev-api-2.4.0 spec/lib/rev/api_spec.rb
rev-api-2.3.2 spec/lib/rev/api_spec.rb