-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathgit_status_spec.rb
More file actions
122 lines (82 loc) · 2.62 KB
/
git_status_spec.rb
File metadata and controls
122 lines (82 loc) · 2.62 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
require 'git-process/git_status'
require 'GitRepoHelper'
require 'fileutils'
describe GitProc::GitStatus do
include GitRepoHelper
def log_level
Logger::ERROR
end
before(:each) do
create_files(%w(.gitignore))
gitlib.commit('initial')
end
after(:each) do
rm_rf(gitlib.workdir)
end
it 'should handle added files' do
create_files(['a', 'b file.txt', 'c'])
gitlib.status.added.should == ['a', 'b file.txt', 'c']
end
it 'should handle a modification on both sides' do
change_file_and_commit('a', '')
gitlib.checkout('fb', :new_branch => 'master')
change_file_and_commit('a', 'hello')
gitlib.checkout('master')
change_file_and_commit('a', 'goodbye')
gitlib.merge('fb') rescue ''
status = gitlib.status
status.unmerged.should == %w(a)
status.modified.should == %w(a)
end
it "should handle an addition on both sides" do
gitlib.checkout('fb', :new_branch => 'master')
change_file_and_commit('a', 'hello')
gitlib.checkout('master')
change_file_and_commit('a', 'goodbye')
gitlib.merge('fb') rescue ''
status = gitlib.status
status.unmerged.should == %w(a)
status.added.should == %w(a)
end
it "should handle a merge deletion on fb" do
change_file_and_commit('a', '')
gitlib.checkout('fb', :new_branch => 'master')
gitlib.remove('a', :force => true)
gitlib.commit('removed a')
gitlib.checkout('master')
change_file_and_commit('a', 'goodbye')
gitlib.merge('fb') rescue ''
status = gitlib.status
status.unmerged.should == %w(a)
status.deleted.should == %w(a)
end
it "should handle a merge deletion on master" do
change_file_and_commit('a', '')
gitlib.checkout('fb', :new_branch => 'master')
change_file_and_commit('a', 'hello')
gitlib.checkout('master')
gitlib.remove('a', :force => true)
gitlib.commit('removed a')
gitlib.merge('fb') rescue ''
status = gitlib.status
status.unmerged.should == %w(a)
status.deleted.should == %w(a)
end
it "should handle a move/rename" do
FileUtils.cp __FILE__, File.join(gitlib.workdir, 'a file.txt')
gitlib.add('a file.txt')
gitlib.commit('a with content')
FileUtils.cp __FILE__, File.join(gitlib.workdir, 'b file.txt')
gitlib.remove 'a file.txt'
gitlib.add 'b file.txt'
status = gitlib.status
status.deleted.should == ['a file.txt']
status.added.should == ['b file.txt']
end
it "should return an empty result" do
gitlib.status.added.should == []
gitlib.status.deleted.should == []
gitlib.status.modified.should == []
gitlib.status.unmerged.should == []
end
end