Sha256: 498de6f86f3257c48f66d93802db4aa62cc7fb02d720071fcfd26204675cbd6b

Contents?: true

Size: 1.3 KB

Versions: 26

Compression:

Stored size: 1.3 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestConfig < Test::Unit::TestCase
  def setup
    @r = Repo.new(GRIT_REPO)
  end
  
  # data
  
  def test_bracketed_fetch
    Git.any_instance.expects(:config).returns(fixture('simple_config'))
    
    config = @r.config
    
    assert_equal "git://github.com/mojombo/grit.git", config["remote.origin.url"]
  end
  
  def test_bracketed_fetch_returns_nil
    Git.any_instance.expects(:config).returns(fixture('simple_config'))
    
    config = @r.config
    
    assert_equal nil, config["unknown"]
  end
  
  def test_fetch
    Git.any_instance.expects(:config).returns(fixture('simple_config'))
    
    config = @r.config
    
    assert_equal "false", config.fetch("core.bare")
  end
  
  def test_fetch_with_default
    Git.any_instance.expects(:config).returns(fixture('simple_config'))
    
    config = @r.config
    
    assert_equal "default", config.fetch("unknown", "default")
  end

  def test_fetch_without_default_raises
    Git.any_instance.expects(:config).returns(fixture('simple_config'))
    
    config = @r.config
    
    assert_raise(IndexError) do
      config.fetch("unknown")
    end
  end
  
  def test_set_value
    Git.any_instance.expects(:config).with({}, 'unknown', 'default')
    
    config = @r.config
    config["unknown"] = "default"
  end
end

Version data entries

26 entries across 26 versions & 12 rubygems

Version Path
boof-grit-1.1.2 test/test_config.rb
cho45-grit-0.8.2 test/test_config.rb
davetron5000-grit-1.1.2 test/test_config.rb
davetron5000-grit-1.1.3 test/test_config.rb
joelmoss-grit-1.1.4 test/test_config.rb
joelmoss-grit-1.1.5 test/test_config.rb
joelmoss-grit-1.1.6 test/test_config.rb
koke-grit-0.8.1 test/test_config.rb
mojombo-grit-0.8.0 test/test_config.rb
mojombo-grit-0.8.1 test/test_config.rb
mojombo-grit-0.9.3 test/test_config.rb
mojombo-grit-0.9.4 test/test_config.rb
pjhyett-grit-0.9.11 test/test_config.rb
pjhyett-grit-0.9.12 test/test_config.rb
relevance-grit-0.8.1 test/test_config.rb
relevance-grit-0.8.3 test/test_config.rb
schacon-grit-0.9.1 test/test_config.rb
schacon-grit-0.9.3 test/test_config.rb
schacon-grit-0.9.4 test/test_config.rb
square-circle-triangle-grit-1.1.3 test/test_config.rb