Sha256: 58f6b001b9bf1c1559701dac40a51837c49fd28e6663f5be9714ab47a5cac149

Contents?: true

Size: 1.84 KB

Versions: 18

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'
describe FuelSDK::Rest do
  let(:client) { FuelSDK::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 'filters url properties from properties leaving 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

18 entries across 18 versions & 2 rubygems

Version Path
fuelsdk_json_bump-0.0.5 spec/rest_spec.rb
fuelsdk-0.1.11 spec/rest_spec.rb
fuelsdk-0.1.9 spec/rest_spec.rb
fuelsdk-0.1.8 spec/rest_spec.rb
fuelsdk-0.1.7 spec/rest_spec.rb
fuelsdk-0.1.6 spec/rest_spec.rb
fuelsdk-0.1.5 spec/rest_spec.rb
fuelsdk-0.1.4 spec/rest_spec.rb
fuelsdk-0.1.3 spec/rest_spec.rb
fuelsdk-0.1.2 spec/rest_spec.rb
fuelsdk-0.1.1 spec/rest_spec.rb
fuelsdk-0.1.0 spec/rest_spec.rb
fuelsdk-0.0.9 spec/rest_spec.rb
fuelsdk-0.0.8 spec/rest_spec.rb
fuelsdk-0.0.7 spec/rest_spec.rb
fuelsdk-0.0.6 spec/rest_spec.rb
fuelsdk-0.0.5 spec/rest_spec.rb
fuelsdk-0.0.4 spec/rest_spec.rb