mirror of https://github.com/tomgi/git_stats.git
integration spec split
This commit is contained in:
parent
db0db46525
commit
41de85737e
|
@ -3,6 +3,9 @@ FactoryGirl.define do
|
|||
|
||||
factory :repo, class: GitStats::GitData::Repo do
|
||||
path "repo_path"
|
||||
factory :test_repo do
|
||||
path 'spec/integration/test_repo'
|
||||
end
|
||||
end
|
||||
|
||||
factory :author, class: GitStats::GitData::Author do
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitStats::GitData::Activity do
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '45677ee') }
|
||||
let(:activity) { repo.activity }
|
||||
|
||||
it 'should count commits by hour' do
|
||||
activity.by_hour.should == {10 => 4, 12 => 3, 13 => 1, 15 => 1, 17 => 1}
|
||||
end
|
||||
|
||||
it 'should count commits by day of week' do
|
||||
activity.by_wday.should == {0 => 3, 3 => 1, 5 => 5, 6 => 1}
|
||||
end
|
||||
|
||||
it 'should count commits by day of week and hour' do
|
||||
activity.by_wday_hour.should == {0 => {12 => 2, 13 => 1}, 3 => {15 => 1}, 5 => {10 => 4, 17 => 1}, 6 => {12 => 1}}
|
||||
end
|
||||
|
||||
it 'should count commits by month' do
|
||||
activity.by_month.should == {10 => 10}
|
||||
end
|
||||
|
||||
it 'should count commits by year' do
|
||||
activity.by_year.should == {2012 => 10}
|
||||
end
|
||||
|
||||
it 'should count commits by year and month' do
|
||||
activity.by_year_month.should == {2012 => {10 => 10}}
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitStats::GitData::Activity do
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '45677ee') }
|
||||
|
||||
let(:tg) { repo.authors.by_email('tomasz.gieniusz@gmail.com') }
|
||||
let(:jd) { repo.authors.by_email('john.doe@gmail.com') }
|
||||
|
||||
it 'should filter commits to author' do
|
||||
tg.commits.map(&:hash).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d 4e7d0e9 45677ee)
|
||||
jd.commits.map(&:hash).should =~ %w(fd66657 81e8bef)
|
||||
end
|
||||
end
|
|
@ -1,19 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitStats::GitData::Repo do
|
||||
let(:repo) { build(:repo, path: 'spec/integration/test_repo', last_commit_hash: '45677ee') }
|
||||
let(:expected_authors) { [
|
||||
build(:author, repo: repo, name: "Tomasz Gieniusz", email: "tomasz.gieniusz@gmail.com"),
|
||||
build(:author, repo: repo, name: "John Doe", email: "john.doe@gmail.com"),
|
||||
] }
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '45677ee') }
|
||||
|
||||
it 'should gather all authors' do
|
||||
repo.authors.should =~ expected_authors
|
||||
repo.authors.should =~ [
|
||||
build(:author, repo: repo, name: "Tomasz Gieniusz", email: "tomasz.gieniusz@gmail.com"),
|
||||
build(:author, repo: repo, name: "John Doe", email: "john.doe@gmail.com"),
|
||||
]
|
||||
end
|
||||
|
||||
it 'should gather all commits sorted by date' do
|
||||
repo.should have(10).commits
|
||||
repo.commits.should be_all { |e| e.is_a? GitStats::GitData::Commit }
|
||||
repo.commits.map(&:hash).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d fd66657 81e8bef 4e7d0e9 45677ee)
|
||||
end
|
||||
|
||||
|
@ -41,32 +38,4 @@ describe GitStats::GitData::Repo do
|
|||
repo.lines_by_extension.should == {'.haml' => 100, '.txt' => 1008, '.rb' => 6}
|
||||
end
|
||||
|
||||
context 'activity' do
|
||||
let(:activity) { repo.activity }
|
||||
|
||||
it 'should count commits by hour' do
|
||||
activity.by_hour.should == {10 => 4, 12 => 3, 13 => 1, 15 => 1, 17 => 1}
|
||||
end
|
||||
|
||||
it 'should count commits by day of week' do
|
||||
activity.by_wday.should == {0 => 3, 3 => 1, 5 => 5, 6 => 1}
|
||||
end
|
||||
|
||||
it 'should count commits by day of week and hour' do
|
||||
activity.by_wday_hour.should == {0 => {12 => 2, 13 => 1}, 3 => {15 => 1}, 5 => {10 => 4, 17 => 1}, 6 => {12 => 1}}
|
||||
end
|
||||
|
||||
it 'should count commits by month' do
|
||||
activity.by_month.should == {10 => 10}
|
||||
end
|
||||
|
||||
it 'should count commits by year' do
|
||||
activity.by_year.should == {2012 => 10}
|
||||
end
|
||||
|
||||
it 'should count commits by year and month' do
|
||||
activity.by_year_month.should == {2012 => {10 => 10}}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue