Sha256: 92c7a940083bfe68ae8431d743cdb3c6c377aa4aab022a8a2dd567e551f304de

Contents?: true

Size: 1.88 KB

Versions: 4

Compression:

Stored size: 1.88 KB

Contents

require File.expand_path("../../spec_helper", __FILE__)

module Vendorificator
  describe Config do
    let(:config){ Config.new }

    describe '#initialize' do
      it' creates a Config object' do
        assert { config.is_a? Config }
      end

      it 'allows to overwrite the default configuration' do
        config = Config.new(:basedir => 'different/basedir')
        assert { config[:basedir] == 'different/basedir' }
      end
    end

    it 'allows to set and get values' do
      assert { config[:new_value] == nil }
      config[:new_value] = 'new value'

      assert { config[:new_value] == 'new value' }
    end

    describe 'extensions' do
      before do
        class Config
          option :custom_option, :default_value
        end
      end

      it 'allows to define custom options' do
        assert { includes_method? Config.new, :custom_option }
      end

      it 'allows to get custom_option value via method' do
        assert { Config.new.custom_option == :default_value }
      end

      it 'allows to set custom_option via method' do
        config.custom_option :custom_value
        assert { config[:custom_option] == :custom_value }
      end

      it 'sets a default value for custom option' do
        assert { Config.new[:custom_option] == :default_value }
      end
    end

    describe 'options' do
      it 'have default values' do
        assert { config[:basedir] == 'vendor' }
        assert { config[:branch_prefix] == 'vendor' }
        assert { config[:remotes] == %w(origin) }
      end

      it 'can be set' do
        assert { includes_method? config, :basedir }
        assert { includes_method? config, :branch_prefix }
        assert { includes_method? config, :remotes }
      end
    end

    describe 'metadata' do
      it 'can be set by user' do
        config.annotate :foo, :bar
        assert { config.metadata[:foo] == :bar }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vendorificator-0.5.git.v0.4.0.63.g8e9d54d spec/vendorificator/config_spec.rb
vendorificator-0.5.git.v0.4.0.60.g9c35209 spec/vendorificator/config_spec.rb
vendorificator-0.5.git.v0.4.0.17.g26d50d8 spec/vendorificator/config_spec.rb
vendorificator-0.4.0 spec/vendorificator/config_spec.rb