git_stats/spec/git_data/commit_range_spec.rb

48 lines
1.4 KiB
Ruby
Raw Normal View History

2012-10-23 20:37:42 +02:00
# -*- encoding : utf-8 -*-
2012-10-19 21:52:20 +02:00
require 'spec_helper'
describe GitStats::GitData::Repo do
let(:repo) { build(:repo) }
describe 'commit range' do
it 'should return HEAD by default' do
repo.commit_range.should == 'HEAD'
end
it 'should return last_commit if it was given' do
2012-10-20 22:38:11 +02:00
repo = build(:repo, last_commit_sha: 'abc')
2012-10-19 21:52:20 +02:00
repo.commit_range.should == 'abc'
end
it 'should return range from first_commit to HEAD if first_commit was given' do
2012-10-20 22:38:11 +02:00
repo = build(:repo, first_commit_sha: 'abc')
2012-10-19 21:52:20 +02:00
repo.commit_range.should == 'abc..HEAD'
end
it 'should return range from first to last commit if both were given' do
2012-10-20 22:38:11 +02:00
repo = build(:repo, first_commit_sha: 'abc', last_commit_sha: 'def')
2012-10-19 21:52:20 +02:00
repo.commit_range.should == 'abc..def'
end
context 'git commands using range' do
2012-10-20 22:38:11 +02:00
let(:repo) { build(:repo, first_commit_sha: 'abc', last_commit_sha: 'def') }
2012-10-19 21:52:20 +02:00
it 'should affect authors command' do
repo.should_receive(:run).with('git shortlog -se abc..def .').and_return("")
2012-10-19 21:52:20 +02:00
repo.authors
end
it 'should affect commits command' do
repo.should_receive(:run).with("git rev-list --pretty=format:'%H|%at|%ai|%aE' abc..def . | grep -v commit").and_return("")
2012-10-19 21:52:20 +02:00
repo.commits
end
it 'should affect project version command' do
repo.should_receive(:run).with('git rev-parse abc..def').and_return("")
2012-10-19 21:52:20 +02:00
repo.project_version
end
end
end
2012-10-23 20:37:42 +02:00
end