@@ -57,46 +57,45 @@ def test_branch_commit
57
57
end
58
58
59
59
def test_branch_create_and_switch
60
- Dir . chdir ( @wdir ) do
61
- assert ( !@ git. branch ( 'new_branch' ) . current )
62
- @ git. branch ( 'other_branch' ) . create
63
- assert ( !@ git. branch ( 'other_branch' ) . current )
64
- @ git. branch ( 'new_branch' ) . checkout
65
- assert ( @ git. branch ( 'new_branch' ) . current )
60
+ in_bare_repo_clone do | git |
61
+ assert ( !git . branch ( 'new_branch' ) . current )
62
+ git . branch ( 'other_branch' ) . create
63
+ assert ( !git . branch ( 'other_branch' ) . current )
64
+ git . branch ( 'new_branch' ) . checkout
65
+ assert ( git . branch ( 'new_branch' ) . current )
66
66
67
- assert_equal ( 1 , @ git. branches . select { |b | b . name == 'new_branch' } . size )
67
+ assert_equal ( 1 , git . branches . select { |b | b . name == 'new_branch' } . size )
68
68
69
69
new_file ( 'test-file1' , 'blahblahblah1' )
70
70
new_file ( 'test-file2' , 'blahblahblah2' )
71
71
new_file ( '.test-dot-file1' , 'blahblahblahdot1' )
72
- assert ( @ git. status . untracked . assoc ( 'test-file1' ) )
73
- assert ( @ git. status . untracked . assoc ( '.test-dot-file1' ) )
72
+ assert ( git . status . untracked . assoc ( 'test-file1' ) )
73
+ assert ( git . status . untracked . assoc ( '.test-dot-file1' ) )
74
74
75
- @ git. add ( [ 'test-file1' , 'test-file2' ] )
76
- assert ( !@ git. status . untracked . assoc ( 'test-file1' ) )
75
+ git . add ( [ 'test-file1' , 'test-file2' ] )
76
+ assert ( !git . status . untracked . assoc ( 'test-file1' ) )
77
77
78
- @ git. reset
79
- assert ( @ git. status . untracked . assoc ( 'test-file1' ) )
80
- assert ( !@ git. status . added . assoc ( 'test-file1' ) )
78
+ git . reset
79
+ assert ( git . status . untracked . assoc ( 'test-file1' ) )
80
+ assert ( !git . status . added . assoc ( 'test-file1' ) )
81
81
82
82
assert_raise Git ::GitExecuteError do
83
- @ git. branch ( 'new_branch' ) . delete
83
+ git . branch ( 'new_branch' ) . delete
84
84
end
85
- assert_equal ( 1 , @ git. branches . select { |b | b . name == 'new_branch' } . size )
85
+ assert_equal ( 1 , git . branches . select { |b | b . name == 'new_branch' } . size )
86
86
87
- @ git. branch ( 'master' ) . checkout
88
- @ git. branch ( 'new_branch' ) . delete
89
- assert_equal ( 0 , @ git. branches . select { |b | b . name == 'new_branch' } . size )
87
+ git . branch ( 'master' ) . checkout
88
+ git . branch ( 'new_branch' ) . delete
89
+ assert_equal ( 0 , git . branches . select { |b | b . name == 'new_branch' } . size )
90
90
91
- @ git. checkout ( 'other_branch' )
92
- assert ( @ git. branch ( 'other_branch' ) . current )
91
+ git . checkout ( 'other_branch' )
92
+ assert ( git . branch ( 'other_branch' ) . current )
93
93
94
- @git . checkout ( 'master' )
95
- assert ( !@git . branch ( 'other_branch' ) . current )
96
-
97
- @git . checkout ( @git . branch ( 'other_branch' ) )
98
- assert ( @git . branch ( 'other_branch' ) . current )
94
+ git . checkout ( 'master' )
95
+ assert ( !git . branch ( 'other_branch' ) . current )
99
96
97
+ git . checkout ( @git . branch ( 'other_branch' ) )
98
+ assert ( git . branch ( 'other_branch' ) . current )
100
99
end
101
100
end
102
101
end
0 commit comments