Sha256: ea0682ad244c7d22e172405b2e92e1c29cdf322c5ab403d9d4ce44b46364fe2a

Contents?: true

Size: 1.41 KB

Versions: 7

Compression:

Stored size: 1.41 KB

Contents

# coding: utf-8
require 'lib/config.rb'
require 'test/unit'

class ConfigTest < Test::Unit::TestCase
  def test_basic_methods_with_default_fixture
    config = Hercules::Config.new 'tests/fixtures/config.yml'
    assert_equal YAML.load_file('tests/fixtures/config.yml'), config.projects
    assert_equal ['target_directory', 'repository', 'token'], Hercules::Config.project_attributes
    assert_equal ['checkout_on_startup', 'checkouts_to_keep'], Hercules::Config.branch_attributes
    assert_equal ['master', 'test'], config.branches['test_project']
  end

  def test_config_attr_reader
    config = Hercules::Config.new 'tests/fixtures/config.yml'
    yml = YAML.load_file('tests/fixtures/config.yml')
    config.each do |k,v|
      assert_equal config[k], yml[k]
    end
  end

  def test_config_validation
    [ 'tests/fixtures/config_empty.yml', 'tests/fixtures/config_empty_branches.yml', 'tests/fixtures/config_empty_projects.yml', 'tests/fixtures/config_partial_1.yml', 'tests/fixtures/config_partial_2.yml', 'tests/fixtures/config_partial_3.yml'].each do |p|
      assert_invalid_config(p) 
    end
  end

  def test_config_with_global_attributes
    config = Hercules::Config.new 'tests/fixtures/config_global.yml'
    assert_equal "127.0.0.1", config.host
    assert_equal 8081, config.port
  end

  def assert_invalid_config path
    assert_raise(Hercules::InvalidConfig) do
      config = Hercules::Config.new(path)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hercules-0.2.6 tests/config_test.rb
hercules-0.2.5 tests/config_test.rb
hercules-0.2.4 tests/config_test.rb
hercules-0.2.3 tests/config_test.rb
hercules-0.2.2 tests/config_test.rb
hercules-0.1.2 tests/config_test.rb
hercules-0.1.1 tests/config_test.rb