From 9da1928faae709f958504451a724d1d555421573 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 29 Sep 2013 17:43:59 +0300 Subject: [PATCH] Use phantomjs for jasmine tests. Fixed broken one --- .../stat_graph_contributors_util_spec.js | 53 ++++++++++--------- spec/javascripts/support/jasmine_helper.rb | 14 ++--- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/spec/javascripts/stat_graph_contributors_util_spec.js b/spec/javascripts/stat_graph_contributors_util_spec.js index 367f0af05f8..2e52479ccbb 100644 --- a/spec/javascripts/stat_graph_contributors_util_spec.js +++ b/spec/javascripts/stat_graph_contributors_util_spec.js @@ -3,10 +3,10 @@ describe("ContributorsStatGraphUtil", function () { describe("#parse_log", function () { it("returns a correctly parsed log", function () { var fake_log = [ - {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}] + {author_email: "karlo@email.com", author_name: "Karlo Soriano", date: "2013-05-09", additions: 471}, + {author_email: "dzaporozhets@email.com", author_name: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 6, deletions: 1}, + {author_email: "dzaporozhets@email.com", author_name: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 19, deletions: 3}, + {author_email: "dzaporozhets@email.com", author_name: "Dmitriy Zaporozhets", date: "2013-05-08", additions: 29, deletions: 3}] var correct_parsed_log = { total: [ @@ -15,11 +15,11 @@ describe("ContributorsStatGraphUtil", function () { by_author: [ { - author: "Karlo Soriano", + author_name: "Karlo Soriano", author_email: "karlo@email.com", "2013-05-09": {date: "2013-05-09", additions: 471, deletions: 0, commits: 1} }, { - author: "Dmitriy Zaporozhets", + author_name: "Dmitriy Zaporozhets",author_email: "dzaporozhets@email.com", "2013-05-08": {date: "2013-05-08", additions: 54, deletions: 7, commits: 3} } ] @@ -112,10 +112,10 @@ describe("ContributorsStatGraphUtil", function () { describe("#add_author", function () { it("adds an author field to the collection", function () { - var fake_author = "Author" + var fake_author = { author_name: "Author", author_email: 'fake@email.com' } var fake_collection = {} ContributorsStatGraphUtil.add_author(fake_author, fake_collection) - expect(fake_collection[fake_author].author).toEqual("Author") + expect(fake_collection[fake_author.author_name].author_name).toEqual("Author") }) }) @@ -153,30 +153,35 @@ describe("ContributorsStatGraphUtil", function () { describe("#get_author_data", function () { it("returns the log by author sorted by specified field", function () { var fake_parsed_log = { - total: [{date: "2013-05-09", additions: 471, deletions: 0, commits: 1}, - {date: "2013-05-08", additions: 54, deletions: 7, commits: 3}], - by_author:[ - { - author: "Karlo Soriano", - "2013-05-09": {date: "2013-05-09", additions: 471, deletions: 0, commits: 1} - }, - { - author: "Dmitriy Zaporozhets", - "2013-05-08": {date: "2013-05-08", additions: 54, deletions: 7, commits: 3} + total: [ + {date: "2013-05-09", additions: 471, deletions: 0, commits: 1}, + {date: "2013-05-08", additions: 54, deletions: 7, commits: 3} + ], + by_author: [ + { + author_name: "Karlo Soriano", author_email: "karlo@email.com", + "2013-05-09": {date: "2013-05-09", additions: 471, deletions: 0, commits: 1} + }, + { + author_name: "Dmitriy Zaporozhets", author_email: "dzaporozhets@email.com", + "2013-05-08": {date: "2013-05-08", additions: 54, deletions: 7, commits: 3} + } + ] } - ]} - var correct_author_data = [{author:"Dmitriy Zaporozhets",dates:{"2013-05-08":3},deletions:7,additions:54,"commits":3}, - {author:"Karlo Soriano",dates:{"2013-05-09":1},deletions:0,additions:471,commits:1}] + var correct_author_data = [ + {author_name:"Dmitriy Zaporozhets",author_email:"dzaporozhets@email.com",dates:{"2013-05-08":3},deletions:7,additions:54,"commits":3}, + {author_name:"Karlo Soriano",author_email:"karlo@email.com",dates:{"2013-05-09":1},deletions:0,additions:471,commits:1} + ] expect(ContributorsStatGraphUtil.get_author_data(fake_parsed_log, "commits")).toEqual(correct_author_data) }) }) describe("#parse_log_entry", function () { it("adds the corresponding info from the log entry to the author", function () { - var fake_log_entry = { author: "Karlo Soriano", + var fake_log_entry = { author_name: "Karlo Soriano", author_email: "karlo@email.com", "2013-05-09": {date: "2013-05-09", additions: 471, deletions: 0, commits: 1} } - var correct_parsed_log = {author:"Karlo Soriano",dates:{"2013-05-09":1},deletions:0,additions:471,commits:1} + var correct_parsed_log = {author_name:"Karlo Soriano",author_email:"karlo@email.com",dates:{"2013-05-09":1},deletions:0,additions:471,commits:1} expect(ContributorsStatGraphUtil.parse_log_entry(fake_log_entry, 'commits', null)).toEqual(correct_parsed_log) }) }) @@ -197,4 +202,4 @@ describe("ContributorsStatGraphUtil", function () { }) -}) \ No newline at end of file +}) diff --git a/spec/javascripts/support/jasmine_helper.rb b/spec/javascripts/support/jasmine_helper.rb index 986a4c16f3e..13e55023b4c 100644 --- a/spec/javascripts/support/jasmine_helper.rb +++ b/spec/javascripts/support/jasmine_helper.rb @@ -1,11 +1,3 @@ -#Use this file to set/override Jasmine configuration options -#You can remove it if you don't need it. -#This file is loaded *after* jasmine.yml is interpreted. -# -#Example: using a different boot file. -#Jasmine.configure do |config| -# @config.boot_dir = '/absolute/path/to/boot_dir' -# @config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] } -#end -# - +Jasmine.configure do |config| + config.browser = :phantomjs +end