Sha256: 95b55acd5a36f2e69d7cc6d73edeb028ecd7b60ecf9c2751cb85a0865a9841a0

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

class ConfigTest < Test::Unit::TestCase
  context "The Config instance" do
    
    should "exist" do
      assert_not_nil AbsoluteRenamer::Config
    end
    
    should "raise ENOENT if config file not found" do
      assert_raise(Errno::ENOENT) do
        AbsoluteRenamer::Config.load('a file that must not be found')
      end  
    end

    should "not raise ENOENT if config file is found" do
      assert_nothing_raised(Errno::ENOENT) do
        AbsoluteRenamer::Config.load('conf/absrenamer/absrenamer.conf')
      end
    end

    context "with a loaded config file" do
      setup do
        AbsoluteRenamer::Config.load('conf/absrenamer/absrenamer.conf')
      end

      should "be able to set and get config options" do
        AbsoluteRenamer::Config.set(:test_key, :test_val)
        assert_equal(:test_val, AbsoluteRenamer::Config.get(:test_key))
      end

      should "be able to set and get a config option with the nil key" do
        AbsoluteRenamer::Config.set(nil, :test_val)
        assert_equal(:test_val, AbsoluteRenamer::Config.get(nil))
      end

      should "be able to set config options using []" do
        AbsoluteRenamer::Config[:test_key] = :test_val
        assert_equal(:test_val, AbsoluteRenamer::Config[:test_key])
      end
      
    end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
simonc-AbsoluteRenamer-0.9.2 test/config_test.rb
AbsoluteRenamer-0.10.0 test/config_test.rb
AbsoluteRenamer-0.10.1 test/config_test.rb
AbsoluteRenamer-0.9.2 test/config_test.rb
AbsoluteRenamer-0.9.1 test/config_test.rb