Sha256: 6c1532c0a785880e8f56d1dbd2f3c194e994beb129958cadf8afe68af9def8c2

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'
describe FuelSDK::Rest do
  let(:client) { FuelSDK::ET_Client.new }

  subject { client }
  it { should respond_to(:rest_get) }
  it { should respond_to(:rest_client) }
  it { should respond_to(:complete_url) }

  describe '#complete_url' do
    it 'raises an exception when identities are missing' do
      expect { client.complete_url "some_url/%{parent}/%{child}", {parent: 1} }.to raise_exception 'key{child} not found to complete some_url/%{parent}/%{child}'
    end

    it 'returns url with all identities replaced' do
      expect( client.complete_url "some_url/%{parent}/%{child}", {:parent => 1, :child => 2} ).to eq 'some_url/1/2'
    end

    it 'handles identities with string keys' do
      expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> 2} ).to eq 'some_url/1/2'
    end

    it 'treats empty values as optional keys' do
      expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> ''} ).to eq 'some_url/1'
    end

    it 'handles extra keys' do
      expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> '', 'other' => 1} ).to eq 'some_url/1'
    end
  end

  describe '#get_url_properties' do
    it 'returns hash of properties in format string' do
      expect( client.get_url_properties "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> '', 'other' => 1} ).to eq({'parent' => 1, 'child' => ''})
    end

    it 'handles missing url properties' do
      expect( client.get_url_properties "some_url/%{parent}/%{child}", {'parent'=> 1, 'other' => 1} ).to eq({'parent' => 1})
    end

    it 'remaining properties are query params' do
      properties = {'parent'=> 1, 'other' => 1}
      client.get_url_properties "some_url/%{parent}/%{child}", properties
      expect(properties).to eq 'other' => 1
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fuelsdk-0.0.3 spec/rest_spec.rb
fuelsdk-0.0.2 spec/rest_spec.rb
fuelsdk-0.0.1 spec/rest_spec.rb