Sha256: 01e3ed90010d78e94dafc6a9db6008b7615890184abf9a2568f10d78c48c4d86

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Acfs::Configuration do
  let(:cfg) { Acfs::Configuration.new }
  before { @configuration = Acfs::Configuration.current.dup }
  after { Acfs::Configuration.set @configuration }

  describe 'Acfs.configure' do
    it 'should invoke configure on current configuration' do
      expect(Acfs::Configuration.current).to receive(:configure).once.and_call_original

      Acfs.configure do |c|
        expect(c).to be_a Acfs::Configuration
      end
    end
  end

  describe '.load' do
    it 'should be able to load YAML' do
      cfg.configure do
        load 'spec/fixtures/config.yml'
      end

      expect(cfg.locate(UserService).to_s).to be == 'http://localhost:3001/'
      expect(cfg.locate(CommentService).to_s).to be == 'http://localhost:3002/'
    end

    context 'with RACK_ENV' do
      before { @env = ENV['RACK_ENV']; ENV['RACK_ENV'] = 'production' }
      after  { ENV['RACK_ENV'] = @env }

      it 'should load ENV block' do
        cfg.configure do
          load 'spec/fixtures/config.yml'
        end

        expect(cfg.locate(UserService).to_s).to be == 'http://user.example.org/'
        expect(cfg.locate(CommentService).to_s).to be == 'http://comment.example.org/'
      end
    end
  end

  describe '#adapter' do
    let(:object) { Object.new }

    it 'should be a accessor' do
      cfg.adapter = object
      expect(cfg.adapter).to eq object
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
acfs-1.6.0 spec/acfs/configuration_spec.rb
acfs-1.5.1 spec/acfs/configuration_spec.rb
acfs-1.5.0 spec/acfs/configuration_spec.rb
acfs-1.4.0 spec/acfs/configuration_spec.rb
acfs-1.3.4 spec/acfs/configuration_spec.rb