Sha256: 48767229e0c021613fb6a2e2a930e8867fd7a5b17fa441a47f6b79c84d131b92

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require_relative '../../../test_helper'

module Troo
  module API
    describe Endpoints do
      let(:described_class) { Endpoints }

      describe '#interpolate' do
        let(:endpoint) { :board_by_id }
        let(:value)    { { external_id: '20001' } }

        subject { described_class.interpolate(endpoint, value) }

        it { subject.must_be_instance_of(String) }

        context 'when the endpoint exists' do
          it 'returns the interpolated endpoint' do
            subject.must_equal('/boards/20001')
          end

          context 'but the endpoint does not need interpolation' do
            let(:endpoint) { :boards_all }

            it 'returns the normal endpoint' do
              subject.must_equal('/members/me/boards')
            end
          end
        end

        context 'when the endpoint does not exist' do
          let(:endpoint) { :wrong_endpoint }

          it 'raises an exception' do
            proc { subject }.must_raise(Troo::EndpointNotFound)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.15 test/lib/troo/api/endpoints_test.rb
troo-0.0.14 test/lib/troo/api/endpoints_test.rb
troo-0.0.13 test/lib/troo/api/endpoints_test.rb