2012-10-13 13:27:15 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GitStats::GitData::Repo do
|
|
|
|
let(:repo) { GitStats::GitData::Repo.new("repo_path") }
|
|
|
|
|
|
|
|
describe 'git output parsing' do
|
|
|
|
before {
|
|
|
|
GitStats::GitData::Command.should_receive(:new).with(
|
|
|
|
repo, 'git shortlog -se HEAD').and_return(
|
|
|
|
double(:run => " 156 John Doe <john.doe@gmail.com>
|
|
|
|
53 Joe Doe <joe.doe@gmail.com>
|
|
|
|
"))
|
|
|
|
}
|
|
|
|
|
|
|
|
it 'should parse git shortlog output to authors hash' do
|
|
|
|
repo.authors.should == {
|
|
|
|
"john.doe@gmail.com" => GitStats::GitData::Author.new(repo: repo, name: "John Doe", email: "john.doe@gmail.com"),
|
|
|
|
"joe.doe@gmail.com" => GitStats::GitData::Author.new(repo: repo, name: "Joe Doe", email: "joe.doe@gmail.com")
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2012-10-13 14:31:52 +02:00
|
|
|
it 'should parse git revlist output to date sorted commits array' do
|
2012-10-13 13:27:15 +02:00
|
|
|
GitStats::GitData::Command.should_receive(:new).with(
|
|
|
|
repo, 'git rev-list --pretty=format:"%h|%at|%ai|%aE" HEAD | grep -v commit').and_return(
|
|
|
|
double(:run => "e4412c3|1348603824|2012-09-25 22:10:24 +0200|john.doe@gmail.com
|
|
|
|
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-13 14:31:52 +02:00
|
|
|
repo.commits.should == [
|
|
|
|
GitStats::GitData::Commit.new(
|
|
|
|
repo: repo, hash: "5eab339", stamp: "1345835073", date: DateTime.parse("2012-08-24 21:04:33 +0200"),
|
2012-10-13 13:27:15 +02:00
|
|
|
author: repo.authors["john.doe@gmail.com"]),
|
2012-10-13 14:31:52 +02:00
|
|
|
GitStats::GitData::Commit.new(
|
2012-10-13 13:27:15 +02:00
|
|
|
repo: repo, hash: "ce34874", stamp: "1347482927", date: DateTime.parse("2012-09-12 22:48:47 +0200"),
|
|
|
|
author: repo.authors["joe.doe@gmail.com"]),
|
2012-10-13 14:31:52 +02:00
|
|
|
GitStats::GitData::Commit.new(
|
|
|
|
repo: repo, hash: "e4412c3", stamp: "1348603824", date: DateTime.parse("2012-09-25 22:10:24 +0200"),
|
2012-10-13 13:27:15 +02:00
|
|
|
author: repo.authors["john.doe@gmail.com"])
|
2012-10-13 14:31:52 +02:00
|
|
|
]
|
2012-10-13 13:27:15 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|