diff options
author | Karlo Soriano <dev+karlo@aelogica.com> | 2013-05-09 09:00:56 +0400 |
---|---|---|
committer | karlo57 <karlo.karlo.karlo@gmail.com> | 2013-06-05 12:51:48 +0400 |
commit | 71d67e6557acb1ce3beeec2c2c6deb35015bd8bb (patch) | |
tree | c8e23f80ee62359d8db8574056ea69ac70eb4406 /spec/lib | |
parent | b9d989dc056a2a2b9316ff9aa06b57c736426871 (diff) |
Contributors graphs feature for GitLab
Created tests and refactored some code along the way
Added stat graph util spec, refactored code
finsihed up tests and refactors
finsihed up tests and refactors
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/git_stats_log_parser_spec.rb | 37 | ||||
-rw-r--r-- | spec/lib/gitlab/git_stats_spec.rb | 36 |
2 files changed, 73 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git_stats_log_parser_spec.rb b/spec/lib/gitlab/git_stats_log_parser_spec.rb new file mode 100644 index 00000000000..c97b32275db --- /dev/null +++ b/spec/lib/gitlab/git_stats_log_parser_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' +require 'gitlab/git_stats_log_parser' + + +describe LogParser do + + describe "#self.parse_log" do + context "log_from_git is a valid log" do + it "returns the correct log" do + fake_log = "Karlo Soriano +2013-05-09 + + 14 files changed, 471 insertions(+) +Dmitriy Zaporozhets +2013-05-08 + + 1 file changed, 6 insertions(+), 1 deletion(-) +Dmitriy Zaporozhets +2013-05-08 + + 6 files changed, 19 insertions(+), 3 deletions(-) +Dmitriy Zaporozhets +2013-05-08 + + 3 files changed, 29 insertions(+), 3 deletions(-)"; + + lp = LogParser.parse_log(fake_log) + lp.should eq([ + {author: "Karlo Soriano", date: "2013-05-09", additions: 471}, + {author: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 6, deletions: 1}, + {author: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 19, deletions: 3}, + {author: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 29, deletions: 3}]) + end + end + end + +end
\ No newline at end of file diff --git a/spec/lib/gitlab/git_stats_spec.rb b/spec/lib/gitlab/git_stats_spec.rb new file mode 100644 index 00000000000..f9c70da2bd5 --- /dev/null +++ b/spec/lib/gitlab/git_stats_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Gitlab::GitStats do + + describe "#parsed_log" do + let(:stats) { Gitlab::GitStats.new(nil, nil) } + before(:each) do + stats.stub(:log).and_return("anything") + end + + context "LogParser#parse_log returns 'test'" do + it "returns 'test'" do + LogParser.stub(:parse_log).and_return("test") + stats.parsed_log.should eq("test") + end + end + end + + describe "#log" do + let(:repo) { Repository.new(nil, nil) } + let(:gs) { Gitlab::GitStats.new(repo.raw, repo.root_ref) } + + before(:each) do + repo.stub(:raw).and_return(nil) + repo.stub(:root_ref).and_return(nil) + repo.raw.stub(:git) + end + + context "repo.git.run returns 'test'" do + it "returns 'test'" do + repo.raw.git.stub(:run).and_return("test") + gs.log.should eq("test") + end + end + end +end
\ No newline at end of file |