@@ -26,9 +26,28 @@ def setup
26
26
end
27
27
end
28
28
29
- def test_branches_all
30
- assert ( @git . branches [ :master ] . is_a? ( Git ::Branch ) )
31
- assert ( @git . branches . size > 5 )
29
+ test 'Git::Base#branches' do
30
+ in_temp_dir do
31
+ remote_git = Git . init ( 'remote_git' , initial_branch : 'master' )
32
+ File . write ( 'remote_git/file.txt' , 'hello world' )
33
+ remote_git . add ( 'file.txt' )
34
+ remote_git . commit ( 'Initial commit' )
35
+ remote_branches = remote_git . branches
36
+ assert_equal ( 1 , remote_branches . size )
37
+ assert ( remote_branches . first . current )
38
+ assert_equal ( 'master' , remote_branches . first . name )
39
+
40
+ # Test that remote tracking branches are handled correctly
41
+ #
42
+ local_git = Git . clone ( 'remote_git/.git' , 'local_git' )
43
+ local_branches = assert_nothing_raised { local_git . branches }
44
+ assert_equal ( 3 , local_branches . size )
45
+ assert ( remote_branches . first . current )
46
+ local_branch_refs = local_branches . map ( &:full )
47
+ assert_include ( local_branch_refs , 'master' )
48
+ assert_include ( local_branch_refs , 'remotes/origin/master' )
49
+ assert_include ( local_branch_refs , 'remotes/origin/HEAD' )
50
+ end
32
51
end
33
52
34
53
def test_branches_local
0 commit comments