-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgit_abstract_merge_error_builder_spec.rb
64 lines (48 loc) · 1.24 KB
/
git_abstract_merge_error_builder_spec.rb
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
require 'git-process/git_abstract_merge_error_builder'
require 'git-process/git_lib'
require 'FileHelpers'
describe GitProc::AbstractMergeErrorBuilder do
def builder
@builder ||= GitProc::AbstractMergeErrorBuilder.new(gitlib, '', nil)
end
after(:each) do
rm_rf(gitlib.workdir)
end
def gitlib
if @lib.nil?
@lib = GitProc::GitLib.new(Dir.mktmpdir, :log_level => Logger::ERROR)
mock_status(@lib)
end
@lib
end
def metaclass(obj)
class << obj
self
end
end
def mock_status(lib)
spec = self
metaclass(lib).send(:define_method, :status) do
@status ||= spec.double('status')
end
end
def match_commands(expected)
commands = builder.commands
expected.each do |e|
commands.slice!(0).should == e
end
commands.should be_empty
end
it "merged with a file added in both branches" do
gitlib.status.stub(:unmerged).and_return(%w(a))
gitlib.status.stub(:modified).and_return(%w(b))
gitlib.status.stub(:added).and_return(%w(a c))
builder.resolved_files.should == %w()
builder.unresolved_files.should == %w(a)
c = [
'# \'a\' was added in both branches; Fix the conflict.',
'git add a',
]
match_commands c
end
end