Sha256: 907f7b3ec9a56ae3b565bdf2540d5dd15febe3c916734623d0773e64e9bff13d

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Acfs::Configuration do
  let(:cfg) { Acfs::Configuration.new }

  around do |example|
    configuration = Acfs::Configuration.current.dup
    example.run
  ensure
    Acfs::Configuration.set(configuration)
  end

  describe 'Acfs.configure' do
    it 'invokes 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 'is able to load YAML' do
      cfg.configure do
        load 'spec/fixtures/config.yml'
      end

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

    context 'with RACK_ENV' do
      around do |example|
        env = ENV.fetch('RACK_ENV', nil)
        ENV['RACK_ENV'] = 'production'
        example.run
      ensure
        ENV['RACK_ENV'] = env
      end

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acfs-2.0.0 spec/acfs/configuration_spec.rb