Sha256: 8b258d8f47949015014084848c0a025618e4e311c4866e026ffb45673cdacc0e

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path "../test_helper", __FILE__

context "Rugged::Config tests" do
  setup do
    @repo = Rugged::Repository.new(test_repo('testrepo.git'))
  end

  test "can read the config file from repo" do
    config = @repo.config
    assert_equal 'false', config['core.bare']
    assert_nil config['not.exist']
  end

  test "can read the config file from path" do
    config = Rugged::Config.new(File.join(@repo.path, 'config'))
    assert_equal 'false', config['core.bare']
  end

  test "can read the global config file" do
    config = Rugged::Config.open_global
    assert_not_nil config['user.name']
    assert_nil config['core.bare']
  end

  test "can write config values" do
    config = @repo.config
    config['custom.value'] = 'my value'

    config2 = @repo.config
    assert_equal 'my value', config2['custom.value']

    content = File.read(File.join(@repo.path, 'config'))
    assert_match /value = my value/, content
  end

  test "can delete config values" do
    config = @repo.config
    config.delete('core.bare')

    config2 = @repo.config
    assert_nil config2.get('core.bare')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rugged-0.17.0b1 test/config_test.rb