spec/properties/api_client_spec.rb in hubspot-api-client-1.0.1 vs spec/properties/api_client_spec.rb in hubspot-api-client-2.0.0
- old
+ new
@@ -10,55 +10,55 @@
=end
require 'spec_helper'
-describe Hubspot::Client::Crm::Properties::ApiClient do
+describe Hubspot::Crm::Properties::ApiClient do
context 'initialization' do
context 'URL stuff' do
context 'host' do
it 'removes http from host' do
Hubspot.configure { |c| c.host = 'http://example.com' }
- expect(Hubspot::Client::Crm::Properties::Configuration.default.host).to eq('example.com')
+ expect(Hubspot::Crm::Properties::Configuration.default.host).to eq('example.com')
end
it 'removes https from host' do
Hubspot.configure { |c| c.host = 'https://wookiee.com' }
- expect(Hubspot::Client::Crm::Properties::ApiClient.default.config.host).to eq('wookiee.com')
+ expect(Hubspot::Crm::Properties::ApiClient.default.config.host).to eq('wookiee.com')
end
it 'removes trailing path from host' do
Hubspot.configure { |c| c.host = 'hobo.com/v4' }
- expect(Hubspot::Client::Crm::Properties::Configuration.default.host).to eq('hobo.com')
+ expect(Hubspot::Crm::Properties::Configuration.default.host).to eq('hobo.com')
end
end
context 'base_path' do
it "prepends a slash to base_path" do
Hubspot.configure { |c| c.base_path = 'v4/dog' }
- expect(Hubspot::Client::Crm::Properties::Configuration.default.base_path).to eq('/v4/dog')
+ expect(Hubspot::Crm::Properties::Configuration.default.base_path).to eq('/v4/dog')
end
it "doesn't prepend a slash if one is already there" do
Hubspot.configure { |c| c.base_path = '/v4/dog' }
- expect(Hubspot::Client::Crm::Properties::Configuration.default.base_path).to eq('/v4/dog')
+ expect(Hubspot::Crm::Properties::Configuration.default.base_path).to eq('/v4/dog')
end
it "ends up as a blank string if nil" do
Hubspot.configure { |c| c.base_path = nil }
- expect(Hubspot::Client::Crm::Properties::Configuration.default.base_path).to eq('')
+ expect(Hubspot::Crm::Properties::Configuration.default.base_path).to eq('')
end
end
end
end
describe 'params_encoding in #build_request' do
- let(:config) { Hubspot::Client::Crm::Properties::Configuration.new }
- let(:api_client) { Hubspot::Client::Crm::Properties::ApiClient.new(config) }
+ let(:config) { Hubspot::Crm::Properties::Configuration.new }
+ let(:api_client) { Hubspot::Crm::Properties::ApiClient.new(config) }
it 'defaults to nil' do
- expect(Hubspot::Client::Crm::Properties::Configuration.default.params_encoding).to eq(nil)
+ expect(Hubspot::Crm::Properties::Configuration.default.params_encoding).to eq(nil)
expect(config.params_encoding).to eq(nil)
request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(nil)
end
@@ -69,15 +69,15 @@
expect(request.options[:params_encoding]).to eq(:multi)
end
end
describe 'timeout in #build_request' do
- let(:config) { Hubspot::Client::Crm::Properties::Configuration.new }
- let(:api_client) { Hubspot::Client::Crm::Properties::ApiClient.new(config) }
+ let(:config) { Hubspot::Crm::Properties::Configuration.new }
+ let(:api_client) { Hubspot::Crm::Properties::ApiClient.new(config) }
it 'defaults to 0' do
- expect(Hubspot::Client::Crm::Properties::Configuration.default.timeout).to eq(0)
+ expect(Hubspot::Crm::Properties::Configuration.default.timeout).to eq(0)
expect(config.timeout).to eq(0)
request = api_client.build_request(:get, '/test')
expect(request.options[:timeout]).to eq(0)
end
@@ -89,29 +89,29 @@
end
end
describe '#deserialize' do
it "handles Array<Integer>" do
- api_client = Hubspot::Client::Crm::Properties::ApiClient.new
+ api_client = Hubspot::Crm::Properties::ApiClient.new
headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[12, 34]')
data = api_client.deserialize(response, 'Array<Integer>')
expect(data).to be_instance_of(Array)
expect(data).to eq([12, 34])
end
it 'handles Array<Array<Integer>>' do
- api_client = Hubspot::Client::Crm::Properties::ApiClient.new
+ api_client = Hubspot::Crm::Properties::ApiClient.new
headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[[12, 34], [56]]')
data = api_client.deserialize(response, 'Array<Array<Integer>>')
expect(data).to be_instance_of(Array)
expect(data).to eq([[12, 34], [56]])
end
it 'handles Hash<String, String>' do
- api_client = Hubspot::Client::Crm::Properties::ApiClient.new
+ api_client = Hubspot::Crm::Properties::ApiClient.new
headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '{"message": "Hello"}')
data = api_client.deserialize(response, 'Hash<String, String>')
expect(data).to be_instance_of(Hash)
expect(data).to eq(:message => 'Hello')
@@ -119,23 +119,23 @@
end
describe "#object_to_hash" do
it 'ignores nils and includes empty arrays' do
# uncomment below to test object_to_hash for model
- # api_client = Hubspot::Client::Crm::Properties::ApiClient.new
- # _model = Hubspot::Client::Crm::Properties::Models::ModelName.new
+ # api_client = Hubspot::Crm::Properties::ApiClient.new
+ # _model = Hubspot::Crm::Properties::ModelName.new
# update the model attribute below
# _model.id = 1
# update the expected value (hash) below
# expected = {id: 1, name: '', tags: []}
# expect(api_client.object_to_hash(_model)).to eq(expected)
end
end
describe '#build_collection_param' do
let(:param) { ['aa', 'bb', 'cc'] }
- let(:api_client) { Hubspot::Client::Crm::Properties::ApiClient.new }
+ let(:api_client) { Hubspot::Crm::Properties::ApiClient.new }
it 'works for csv' do
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
end
@@ -159,11 +159,11 @@
expect{api_client.build_collection_param(param, :INVALID)}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
end
end
describe '#json_mime?' do
- let(:api_client) { Hubspot::Client::Crm::Properties::ApiClient.new }
+ let(:api_client) { Hubspot::Crm::Properties::ApiClient.new }
it 'works' do
expect(api_client.json_mime?(nil)).to eq false
expect(api_client.json_mime?('')).to eq false
@@ -176,11 +176,11 @@
expect(api_client.json_mime?('application/jsonp')).to eq false
end
end
describe '#select_header_accept' do
- let(:api_client) { Hubspot::Client::Crm::Properties::ApiClient.new }
+ let(:api_client) { Hubspot::Crm::Properties::ApiClient.new }
it 'works' do
expect(api_client.select_header_accept(nil)).to be_nil
expect(api_client.select_header_accept([])).to be_nil
@@ -192,11 +192,11 @@
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
end
end
describe '#select_header_content_type' do
- let(:api_client) { Hubspot::Client::Crm::Properties::ApiClient.new }
+ let(:api_client) { Hubspot::Crm::Properties::ApiClient.new }
it 'works' do
expect(api_client.select_header_content_type(nil)).to eq('application/json')
expect(api_client.select_header_content_type([])).to eq('application/json')
@@ -207,10 +207,10 @@
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
end
end
describe '#sanitize_filename' do
- let(:api_client) { Hubspot::Client::Crm::Properties::ApiClient.new }
+ let(:api_client) { Hubspot::Crm::Properties::ApiClient.new }
it 'works' do
expect(api_client.sanitize_filename('sun')).to eq('sun')
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')