2012-10-23 20:37:42 +02:00
|
|
|
# -*- encoding : utf-8 -*-
|
2012-10-13 13:27:15 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GitStats::GitData::Repo do
|
2012-10-16 20:52:22 +02:00
|
|
|
let(:repo) { build(:repo) }
|
2012-10-19 21:11:47 +02:00
|
|
|
|
2012-10-13 13:27:15 +02:00
|
|
|
describe 'git output parsing' do
|
2012-10-19 20:02:47 +02:00
|
|
|
context 'invoking authors command' do
|
|
|
|
before do
|
2014-03-30 08:01:39 +02:00
|
|
|
repo.should_receive(:run).with('git shortlog -se HEAD .').and_return(" 156 John Doe <john.doe@gmail.com>
|
2012-10-13 13:27:15 +02:00
|
|
|
53 Joe Doe <joe.doe@gmail.com>
|
2012-10-16 21:31:25 +02:00
|
|
|
")
|
2012-10-19 20:02:47 +02:00
|
|
|
end
|
|
|
|
it 'should parse git shortlog output to authors hash' do
|
2012-10-19 21:52:20 +02:00
|
|
|
repo.authors.should == [
|
|
|
|
build(:author, repo: repo, name: "John Doe", email: "john.doe@gmail.com"),
|
|
|
|
build(:author, repo: repo, name: "Joe Doe", email: "joe.doe@gmail.com")
|
|
|
|
]
|
2012-10-19 20:02:47 +02:00
|
|
|
end
|
2012-10-13 13:27:15 +02:00
|
|
|
|
2012-10-19 20:02:47 +02:00
|
|
|
it 'should parse git revlist output to date sorted commits array' do
|
2014-03-30 08:01:39 +02:00
|
|
|
repo.should_receive(:run).with("git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD . | grep -v commit").and_return(
|
2012-10-19 20:02:47 +02:00
|
|
|
"e4412c3|1348603824|2012-09-25 22:10:24 +0200|john.doe@gmail.com
|
2012-10-13 13:27:15 +02:00
|
|
|
ce34874|1347482927|2012-09-12 22:48:47 +0200|joe.doe@gmail.com
|
|
|
|
5eab339|1345835073|2012-08-24 21:04:33 +0200|john.doe@gmail.com
|
2012-10-16 21:31:25 +02:00
|
|
|
")
|
|
|
|
|
2012-10-19 20:02:47 +02:00
|
|
|
repo.commits.should == [
|
|
|
|
GitStats::GitData::Commit.new(
|
2012-10-20 22:38:11 +02:00
|
|
|
repo: repo, sha: "5eab339", stamp: "1345835073", date: DateTime.parse("2012-08-24 21:04:33 +0200"),
|
2012-10-19 20:02:47 +02:00
|
|
|
author: repo.authors.by_email("john.doe@gmail.com")),
|
|
|
|
GitStats::GitData::Commit.new(
|
2012-10-20 22:38:11 +02:00
|
|
|
repo: repo, sha: "ce34874", stamp: "1347482927", date: DateTime.parse("2012-09-12 22:48:47 +0200"),
|
2012-10-19 20:02:47 +02:00
|
|
|
author: repo.authors.by_email("joe.doe@gmail.com")),
|
|
|
|
GitStats::GitData::Commit.new(
|
2012-10-20 22:38:11 +02:00
|
|
|
repo: repo, sha: "e4412c3", stamp: "1348603824", date: DateTime.parse("2012-09-25 22:10:24 +0200"),
|
2012-10-19 20:02:47 +02:00
|
|
|
author: repo.authors.by_email("john.doe@gmail.com"))
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
it 'should parse git rev-parse command to project version' do
|
|
|
|
repo.should_receive(:run).with('git rev-parse --short HEAD').and_return('xyz')
|
|
|
|
repo.project_version.should == 'xyz'
|
2012-10-13 13:27:15 +02:00
|
|
|
end
|
|
|
|
end
|
2012-10-23 20:37:42 +02:00
|
|
|
end
|