2012-10-23 20:37:42 +02:00
|
|
|
# -*- encoding : utf-8 -*-
|
2012-10-12 18:20:07 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GitStats::Generator do
|
|
|
|
let(:repo_path) { 'repo_path' }
|
|
|
|
let(:out_path) { 'out_path' }
|
|
|
|
let(:generator) { GitStats::Generator.new(repo_path, out_path) }
|
|
|
|
|
|
|
|
before { Dir.stub!(:exists? => true) }
|
|
|
|
|
|
|
|
it 'should raise exception if given repo path is not a git repository' do
|
|
|
|
Dir.should_receive(:exists?).with("#{repo_path}/.git").and_return(false)
|
2012-10-19 21:11:47 +02:00
|
|
|
expect { generator }.to raise_error(ArgumentError)
|
2012-10-12 18:20:07 +02:00
|
|
|
end
|
|
|
|
|
2012-10-19 21:11:47 +02:00
|
|
|
it 'should pass command observer to repo' do
|
|
|
|
repo = double('repo')
|
2013-04-06 14:52:01 +02:00
|
|
|
GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, first_commit_sha: nil, last_commit_sha: "HEAD").and_return(repo)
|
2012-10-19 21:11:47 +02:00
|
|
|
|
|
|
|
generator = GitStats::Generator.new(repo_path, out_path)
|
|
|
|
|
|
|
|
observer = double('observer')
|
|
|
|
repo.should_receive(:add_command_observer).with(observer)
|
|
|
|
|
|
|
|
generator.add_command_observer observer
|
2012-10-12 18:20:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should render all templates with view data for this repo' do
|
|
|
|
repo = double('repo')
|
2013-04-06 14:52:01 +02:00
|
|
|
GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, first_commit_sha: nil, last_commit_sha: "HEAD").and_return(repo)
|
2012-10-12 18:20:07 +02:00
|
|
|
|
|
|
|
view_data = double('view_data')
|
|
|
|
GitStats::StatsView::ViewData.should_receive(:new).with(repo).and_return(view_data)
|
|
|
|
|
2012-10-13 14:01:46 +02:00
|
|
|
view = double('view')
|
|
|
|
GitStats::StatsView::View.should_receive(:new).with(view_data, out_path).and_return(view)
|
|
|
|
view.should_receive(:render_all)
|
2012-10-12 18:20:07 +02:00
|
|
|
|
2012-10-19 21:11:47 +02:00
|
|
|
generator.render_all
|
2012-10-12 18:20:07 +02:00
|
|
|
end
|
2012-10-23 20:37:42 +02:00
|
|
|
end
|