Sha256: d1f86c61913122b19fc05c7207fbc44afba654907e660a8f859b127b7c8b4e96

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

require_relative '../../spec_helper'

describe Rev::HttpClient do
  it 'must support predefined production host' do
    client = Rev::HttpClient.new('foo', 'bar', Rev::Api::PRODUCTION_HOST)
    Rev::HttpClient.base_uri.must_equal 'https://www.rev.com/api/v1'
  end

  it 'must support predefined sandbox host' do
    client = Rev::HttpClient.new('foo', 'bar', Rev::Api::SANDBOX_HOST)
    Rev::HttpClient.base_uri.must_equal 'https://api-sandbox.rev.com/api/v1'
  end

  it 'must support custom host for development purposes' do
    client = Rev::HttpClient.new('foo', 'bar', 'localhost')
    Rev::HttpClient.base_uri.must_equal 'https://localhost/api/v1'
  end

  it 'must include authorization and User-Agent headers for any request' do
    host = 'www.example.com'
    stub_request(:any, /www\.example\.com\/.*/)

    client = Rev::HttpClient.new('foo', 'bar', host)
    response = client.get('/orders')

    assert_requested :get, "https://#{host}/api/v1/orders", :headers => {
      'Authorization' => "Rev foo:bar",
      'User-Agent' => Rev::HttpClient::USER_AGENT
    }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rev-api-2.4.0 spec/lib/rev/http_client_spec.rb
rev-api-2.3.2 spec/lib/rev/http_client_spec.rb
rev-api-2.3.0 spec/lib/rev/http_client_spec.rb
rev-api-2.2.1 spec/lib/rev/http_client_spec.rb
rev-api-2.1.0 spec/lib/rev/http_client_spec.rb
rev-api-2.0.3 spec/lib/rev/http_client_spec.rb
rev-api-2.0.2 spec/lib/rev/http_client_spec.rb
rev-api-2.0.1 spec/lib/rev/http_client_spec.rb