square-circle-triangle-grit 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_tree.rb ADDED
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestTree < Test::Unit::TestCase
4
+ def setup
5
+ @r = Repo.new(GRIT_REPO)
6
+ @t = Tree.allocate
7
+ end
8
+
9
+ # contents
10
+ def test_nosuch_tree
11
+ t = @r.tree('blahblah')
12
+ assert t.contents.is_a?(Array)
13
+ assert t.is_a?(Tree)
14
+ end
15
+
16
+ def test_contents_should_cache
17
+ Git.any_instance.expects(:ls_tree).returns(
18
+ fixture('ls_tree_a'),
19
+ fixture('ls_tree_b')
20
+ ).times(2)
21
+ tree = @r.tree('master')
22
+
23
+ child = tree.contents.last
24
+
25
+ child.contents
26
+ child.contents
27
+ end
28
+
29
+ # content_from_string
30
+
31
+ def test_content_from_string_tree_should_return_tree
32
+ text = fixture('ls_tree_a').split("\n").last
33
+
34
+ tree = @t.content_from_string(nil, text)
35
+
36
+ assert_equal Tree, tree.class
37
+ assert_equal "650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44", tree.id
38
+ assert_equal "040000", tree.mode
39
+ assert_equal "test", tree.name
40
+ end
41
+
42
+ def test_content_from_string_tree_should_return_blob
43
+ text = fixture('ls_tree_b').split("\n").first
44
+
45
+ tree = @t.content_from_string(nil, text)
46
+
47
+ assert_equal Blob, tree.class
48
+ assert_equal "aa94e396335d2957ca92606f909e53e7beaf3fbb", tree.id
49
+ assert_equal "100644", tree.mode
50
+ assert_equal "grit.rb", tree.name
51
+ end
52
+
53
+ def test_content_from_string_tree_should_return_submodule
54
+ text = fixture('ls_tree_submodule').split("\n").first
55
+
56
+ sm = @t.content_from_string(nil, text)
57
+
58
+ assert_kind_of Submodule, sm
59
+ end
60
+
61
+ def test_content_from_string_invalid_type_should_raise
62
+ assert_raise(RuntimeError) do
63
+ @t.content_from_string(nil, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test")
64
+ end
65
+ end
66
+
67
+ # /
68
+
69
+ def test_slash
70
+ Git.any_instance.expects(:ls_tree).returns(
71
+ fixture('ls_tree_a')
72
+ )
73
+ tree = @r.tree('master')
74
+
75
+ assert_equal 'aa06ba24b4e3f463b3c4a85469d0fb9e5b421cf8', (tree/'lib').id
76
+ assert_equal '8b1e02c0fb554eed2ce2ef737a68bb369d7527df', (tree/'README.txt').id
77
+ end
78
+
79
+ def test_slash_with_commits
80
+ Git.any_instance.expects(:ls_tree).returns(
81
+ fixture('ls_tree_commit')
82
+ )
83
+ tree = @r.tree('master')
84
+
85
+ assert_equal 'd35b34c6e931b9da8f6941007a92c9c9a9b0141a', (tree/'bar').id
86
+ assert_equal '2afb47bcedf21663580d5e6d2f406f08f3f65f19', (tree/'foo').id
87
+ assert_equal 'f623ee576a09ca491c4a27e48c0dfe04be5f4a2e', (tree/'baz').id
88
+ end
89
+
90
+ # inspect
91
+
92
+ def test_inspect
93
+ @t = Tree.create(@r, :id => 'abc')
94
+ assert_equal %Q{#<Grit::Tree "abc">}, @t.inspect
95
+ end
96
+
97
+ def test_basename
98
+ @t = Tree.create(@r, :name => 'foo/bar')
99
+ assert_equal "bar", @t.basename
100
+ end
101
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: square-circle-triangle-grit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-03-31 00:00:00 -07:00
13
+ date: 2009-07-03 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -39,14 +39,15 @@ executables: []
39
39
 
40
40
  extensions: []
41
41
 
42
- extra_rdoc_files: []
43
-
42
+ extra_rdoc_files:
43
+ - LICENSE
44
+ - README.md
44
45
  files:
45
46
  - API.txt
46
47
  - History.txt
47
48
  - README.md
48
49
  - VERSION.yml
49
- - lib/grit
50
+ - lib/grit.rb
50
51
  - lib/grit/actor.rb
51
52
  - lib/grit/blame.rb
52
53
  - lib/grit/blob.rb
@@ -55,18 +56,16 @@ files:
55
56
  - lib/grit/config.rb
56
57
  - lib/grit/diff.rb
57
58
  - lib/grit/errors.rb
58
- - lib/grit/git-ruby
59
+ - lib/grit/git-ruby.rb
59
60
  - lib/grit/git-ruby/commit_db.rb
60
61
  - lib/grit/git-ruby/file_index.rb
61
62
  - lib/grit/git-ruby/git_object.rb
62
- - lib/grit/git-ruby/internal
63
63
  - lib/grit/git-ruby/internal/file_window.rb
64
64
  - lib/grit/git-ruby/internal/loose.rb
65
65
  - lib/grit/git-ruby/internal/pack.rb
66
66
  - lib/grit/git-ruby/internal/raw_object.rb
67
67
  - lib/grit/git-ruby/object.rb
68
68
  - lib/grit/git-ruby/repository.rb
69
- - lib/grit/git-ruby.rb
70
69
  - lib/grit/git.rb
71
70
  - lib/grit/index.rb
72
71
  - lib/grit/lazy.rb
@@ -78,13 +77,12 @@ files:
78
77
  - lib/grit/submodule.rb
79
78
  - lib/grit/tag.rb
80
79
  - lib/grit/tree.rb
81
- - lib/grit.rb
82
80
  - lib/open3_detach.rb
83
- has_rdoc: true
81
+ - LICENSE
82
+ has_rdoc: false
84
83
  homepage: http://github.com/mojombo/grit
85
84
  post_install_message:
86
85
  rdoc_options:
87
- - --inline-source
88
86
  - --charset=UTF-8
89
87
  require_paths:
90
88
  - lib
@@ -105,7 +103,39 @@ requirements: []
105
103
  rubyforge_project: grit
106
104
  rubygems_version: 1.2.0
107
105
  signing_key:
108
- specification_version: 2
106
+ specification_version: 3
109
107
  summary: Grit is a Ruby library for extracting information from a git repository in an object oriented manner.
110
- test_files: []
111
-
108
+ test_files:
109
+ - test/bench/benchmarks.rb
110
+ - test/helper.rb
111
+ - test/profile.rb
112
+ - test/suite.rb
113
+ - test/test_actor.rb
114
+ - test/test_blame.rb
115
+ - test/test_blame_tree.rb
116
+ - test/test_blob.rb
117
+ - test/test_commit.rb
118
+ - test/test_commit_stats.rb
119
+ - test/test_commit_write.rb
120
+ - test/test_config.rb
121
+ - test/test_diff.rb
122
+ - test/test_file_index.rb
123
+ - test/test_git.rb
124
+ - test/test_grit.rb
125
+ - test/test_head.rb
126
+ - test/test_index_status.rb
127
+ - test/test_merge.rb
128
+ - test/test_raw.rb
129
+ - test/test_real.rb
130
+ - test/test_reality.rb
131
+ - test/test_remote.rb
132
+ - test/test_repo.rb
133
+ - test/test_rubygit.rb
134
+ - test/test_rubygit_alt.rb
135
+ - test/test_rubygit_index.rb
136
+ - test/test_rubygit_iv2.rb
137
+ - test/test_submodule.rb
138
+ - test/test_tag.rb
139
+ - test/test_tree.rb
140
+ - examples/ex_add_commit.rb
141
+ - examples/ex_index.rb