Sha256: e8992cafde24cb160c4080f18493560c9b8729a2d13c3f1ad238675543a2272b

Contents?: true

Size: 894 Bytes

Versions: 2

Compression:

Stored size: 894 Bytes

Contents

# coding: utf-8

module Confuse
  class TestDefinition < MiniTest::Unit::TestCase
    def setup
      @definition = Confuse::Definition.new do |d|
        d.add_item :foo, :default => 1
        d.add_namespace :bar do |n|
          n.add_item(:foo, :default => 1, :description => 'test')
        end
      end
    end

    def source
      @source ||= Confuse.source
    end

    def config
      @config ||= Confuse::Config.new(@definition, source)
    end

    # can define a configuration item
    def test_define_item
      assert @definition.defines? :foo
    end

    # can define a namespace
    def test_define_namespace
      assert @definition.defines? :bar_foo
    end

    def test_to_hash
      assert_equal(
        { :foo => { :description => nil, :default => 1 },
          :bar_foo => { :description => 'test', :default => 1 } },
        @definition.to_hash)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confuse-1.1.1 test/test_definition.rb
confuse-1.1.0 test/test_definition.rb