Skip to content

Commit

Permalink
More specs for Git::Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozuras committed Sep 10, 2014
1 parent fbf8d76 commit 8002773
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pronto/git/patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def blame(lineno)

def lines
@lines ||= begin
hunks.map do |hunk|
hunks.flat_map do |hunk|
hunk.lines.map { |line| Line.new(line, self, hunk) }
end.flatten.compact
end
end
end

Expand Down
18 changes: 18 additions & 0 deletions spec/pronto/git/patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ module Git
let(:rugged_patch) { double(stat: [5, 17]) }
it { should == 17 }
end

describe '#lines' do
subject { patch.lines }

let(:hunks) { [double(lines: [1, 2]), double(lines: [3])] }
let(:rugged_patch) { double(hunks: hunks) }
its(:count) { should == 3 }
end

describe '#new_file_full_path' do
subject { patch.new_file_full_path }

let(:rugged_patch) do
double(delta: double(new_file: { path: 'test.md' }))
end
let(:repo) { double(path: '/house/of/cards/orig.md') }
its(:to_s) { should == '/house/of/cards/test.md' }
end
end
end
end

0 comments on commit 8002773

Please sign in to comment.