Sha256: bbd715c2da60515afb158e7304b437cf5c6ac62de0163b55281b870eb48ae916

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Acfs::Service do
  let(:srv_class) { Class.new(Acfs::Service) { identity :test } }
  let(:options) { {} }
  let(:service) { srv_class.new(**options) }

  before do
    Acfs::Configuration.current.locate :test, ''
  end

  describe '#initialize' do
    let(:options) { {path: 'abc', key: 'value'} }

    it 'sets options' do
      expect(service.options).to eq(options)
    end
  end

  describe '#location' do
    let(:resource) { Class.new }

    before { allow(resource).to receive(:location_default_path, &proc {|_a, p| p }) }

    it 'extracts resource path name from given class' do
      expect(service.location(resource).to_s).to eq('/classes')
    end

    context 'with path options' do
      let(:options) { {path: 'abc'} }

      it 'has custom resource path' do
        expect(service.location(resource).to_s).to eq('/abc')
      end
    end
  end

  describe '.base_url' do
    before do
      Acfs::Configuration.current.locate :test, 'http://abc.de/api/v1'
    end

    it 'returns configured URI for service' do
      expect(srv_class.base_url).to eq('http://abc.de/api/v1')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acfs-2.0.0 spec/acfs/service_spec.rb
acfs-1.7.0 spec/acfs/service_spec.rb