git_stats/spec/git_data/short_stat_spec.rb

29 lines
1.1 KiB
Ruby
Raw Normal View History

2012-10-23 20:37:42 +02:00
# -*- encoding : utf-8 -*-
2012-10-16 20:52:22 +02:00
require 'spec_helper'
describe GitStats::GitData::ShortStat do
2012-10-20 22:38:11 +02:00
let(:commit) { build(:commit, sha: 'abc') }
2012-10-16 20:52:22 +02:00
describe 'git output parsing' do
context 'parsing git show output' do
[
{content: '2 files changed, 17 insertions(+), 3 deletions(-)', expect: [2, 17, 3]},
{content: '1 file changed, 1 insertion(+), 1 deletion(-)', expect: [1, 1, 1]},
{content: '2 files changed, 3 deletions(-)', expect: [2, 0, 3]},
{content: '2 files changed, 5 insertions(+)', expect: [2, 5, 0]},
{content: '', expect: [0, 0, 0]},
].each do |test|
it "#{test[:content]} parsing" do
commit.repo.should_receive(:run).with("git show --shortstat --oneline abc -- .").and_return("abc some commit\n#{test[:content]}")
2012-10-16 20:52:22 +02:00
commit.short_stat.should be_a(GitStats::GitData::ShortStat)
commit.short_stat.files_changed.should == test[:expect][0]
commit.short_stat.insertions.should == test[:expect][1]
commit.short_stat.deletions.should == test[:expect][2]
end
end
end
end
2012-10-23 20:37:42 +02:00
end