Sha256: d52d5897e02608e6e076b93efc14f90452b93480f091ab13399aab8981c296fa

Contents?: true

Size: 1.87 KB

Versions: 12

Compression:

Stored size: 1.87 KB

Contents

#!/usr/bin/ruby

$: << "../lib"


require 'runit/testcase'
require 'runit/cui/testrunner'
require 'jiji/configuration'

class ConfigurationTest <  RUNIT::TestCase

  def setup
  end

  def teardown
  end

  def test_basic
    conf = JIJI::Configuration.new  File.dirname(__FILE__) + "/test_Configuration_a.yaml"
    
    assert_equals conf.key?( [:a] ), true
    assert_equals conf.key?( [:aa, :a] ), true
    assert_equals conf.key?( [:x] ), false
    
    assert_equals "aaa", conf.get( [:a], "foo" )
    assert_equals 10,    conf.get( [:b], "foo" )
    assert_equals "foo", conf.get( [:c], "foo" )
    assert_equals "foo", conf.get( [:d], "foo" )
    assert_equals "aaa", conf.get( [:aa, :a], "foo" )
    assert_equals "foo", conf.get( [:aa, :b], "foo" )
    assert_equals "foo", conf.get( [:aa, :a, :b], "foo" )
    assert_equals "foo", conf.get( [:bb], "foo" )
    assert_equals "foo", conf.get( [:bb, :b], "foo" )
        
    conf.set( [:a], "x" )
    conf.set( [:x], "x" )
    conf.set( [:aa, :a], "x" )
    conf.set( [:aa, :x], "x" )
    conf.set( [:xxx, :xx, :x], "x" )
    
    assert_equals "x", conf.get( [:a], "foo" )
    assert_equals "x", conf.get( [:x], "foo" )
    assert_equals "x", conf.get( [:aa, :a], "foo" )
    assert_equals "x", conf.get( [:aa, :x], "foo" )
    assert_equals "x", conf.get( [:xxx, :xx, :x], "foo" )
    
    
    conf = JIJI::Configuration.new  File.dirname(__FILE__) + "/not found.yaml"
    assert_equals "foo", conf.get( [:a], "foo" )
    assert_equals "foo", conf.get( [:b], "foo" )
    assert_equals "foo", conf.get( [:c], "foo" )
    assert_equals "foo", conf.get( [:d], "foo" )
    assert_equals "foo", conf.get( [:aa, :a], "foo" )
    assert_equals "foo", conf.get( [:aa, :b], "foo" )
    assert_equals "foo", conf.get( [:aa, :a, :b], "foo" )
    assert_equals "foo", conf.get( [:bb], "foo" )
    assert_equals "foo", conf.get( [:bb, :b], "foo" )
    
  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
unageanu-jiji-1.1.0 test/test_Configuration.rb
unageanu-jiji-1.1.1 test/test_Configuration.rb
unageanu-jiji-1.1.2 test/test_Configuration.rb
unageanu-jiji-1.1.3 test/test_Configuration.rb
unageanu-jiji-1.1.4 test/test_Configuration.rb
unageanu-jiji-1.2.1 test/test_Configuration.rb
unageanu-jiji-1.2.3 test/test_Configuration.rb
unageanu-jiji-1.2.4 test/test_Configuration.rb
jiji-1.2.8 test/test_Configuration.rb
jiji-1.2.7 test/test_Configuration.rb
jiji-1.2.6 test/test_Configuration.rb
jiji-1.2.5 test/test_Configuration.rb