Sha256: ce0547accdb19428f7b89dc3170d7ee375af13d1d5fb1f19ce3130a35ec91231

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe LB::Project, '.config' do
  subject { object.config }

  let(:object) { described_class }

  let(:default_hash) do
    {
      base_path: '',
      image_base_path: 'assets/images',
      public_path: 'docs',
      template_path: 'templates'
    }
  end

  let(:default) { LB::Project::Config.new(default_hash) }

  let(:env) { 'RACK_ENV' }

  before(:each) do
    root = LB::Project.root_for(__FILE__, 6)
    LB::Project.setup(File.join(root, 'spec/fixtures'))
  end

  after(:each) do
    object.remove_instance_variable(:@rack_env)
    object.remove_instance_variable(:@config)
    object.remove_instance_variable(:@root)
  end

  context 'without RACK_ENV' do
    it 'should return default config' do
      expect(subject).to eql(default)
    end
  end

  context 'with RACK_ENV=production' do
    let(:production_hash) { default_hash.merge(public_path: 'htdocs') }
    let(:production) { LB::Project::Config.new(production_hash) }
    let(:rack_env) { 'production' }

    before(:each) do
      ENV[env] = rack_env
    end

    after(:each) do
      ENV.delete(env)
    end

    it 'should return production config' do
      expect(subject).to eql(production)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lb-project-0.0.1 spec/unit/lb/project/class_methods/config_spec.rb