public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/dustin/gitnub.git
Search Repo:
gitnub / grit / test / test_config.rb
100644 59 lines (39 sloc) 1.336 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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