git_statistics 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/commits_spec.rb DELETED
@@ -1,381 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- include GitStatistics
3
-
4
- describe Commits do
5
- describe "#authors" do
6
- context "with one author" do
7
- commits = Commits.new
8
- commits.load(fixture("single_author.json"))
9
- author_list = commits.authors
10
-
11
-
12
- it { author_list.size.should be(1) }
13
- it { author_list[0].should == "Kevin Jalbert" }
14
- end
15
-
16
- context "with many authors" do
17
- commits = Commits.new
18
- commits.load(fixture("many_authors.json"))
19
- author_list = commits.authors
20
-
21
- it { author_list.size.should be(3) }
22
- it { author_list[0].should == "Bart Simpson" }
23
- it { author_list[1].should == "Kevin Jalbert" }
24
- it { author_list[2].should == "Maggie Simpson" }
25
- end
26
-
27
- context "with no authors" do
28
- commits = Commits.new
29
- author_list = commits.authors
30
-
31
- it { author_list.size.should be(0) }
32
- end
33
- end
34
-
35
- describe "#authors_email" do
36
- context "with one author" do
37
- commits = Commits.new
38
- commits.load(fixture("single_author.json"))
39
- author_list = commits.authors_email
40
-
41
- it { author_list.size.should be(1) }
42
- it { author_list[0].should == "kevin.j.jalbert@gmail.com" }
43
- end
44
-
45
- context "with many authors" do
46
- commits = Commits.new
47
- commits.load(fixture("many_authors.json"))
48
- author_list = commits.authors_email
49
-
50
- it { author_list.size.should be(3) }
51
- it { author_list[0].should == "bart.simpson@gmail.com" }
52
- it { author_list[1].should == "kevin.j.jalbert@gmail.com" }
53
- it { author_list[2].should == "maggie.simpson@gmail.com" }
54
- end
55
-
56
- context "with no authors" do
57
- commits = Commits.new
58
- author_list = commits.authors_email
59
-
60
- it { author_list.size.should be(0) }
61
- end
62
- end
63
-
64
- describe "#authors_statistics" do
65
- context "with email" do
66
- context "with merge" do
67
- commits = Commits.new
68
- commits.load(fixture("many_authors.json"))
69
- results = commits.authors_statistics(true, true)
70
-
71
- it {results.size.should be(3)}
72
- it {results["bart.simpson@gmail.com"][:commits].should be(2)}
73
- it {results["bart.simpson@gmail.com"][:insertions].should be(13)}
74
- it {results["bart.simpson@gmail.com"][:deletions].should be(3)}
75
- it {results["bart.simpson@gmail.com"][:creates].should be(2)}
76
- it {results["bart.simpson@gmail.com"][:deletes].should be(0)}
77
- it {results["bart.simpson@gmail.com"][:renames].should be(2)}
78
- it {results["bart.simpson@gmail.com"][:copies].should be(0)}
79
- it {results["bart.simpson@gmail.com"][:merges].should be(1)}
80
-
81
- it {results["kevin.j.jalbert@gmail.com"][:commits].should be(1)}
82
- it {results["kevin.j.jalbert@gmail.com"][:insertions].should be(62)}
83
- it {results["kevin.j.jalbert@gmail.com"][:deletions].should be(6)}
84
- it {results["kevin.j.jalbert@gmail.com"][:creates].should be(0)}
85
- it {results["kevin.j.jalbert@gmail.com"][:deletes].should be(1)}
86
- it {results["kevin.j.jalbert@gmail.com"][:renames].should be(0)}
87
- it {results["kevin.j.jalbert@gmail.com"][:copies].should be(0)}
88
- it {results["kevin.j.jalbert@gmail.com"][:merges].should be(1)}
89
-
90
- it {results["maggie.simpson@gmail.com"][:commits].should be(2)}
91
- it {results["maggie.simpson@gmail.com"][:insertions].should be(211)}
92
- it {results["maggie.simpson@gmail.com"][:deletions].should be(192)}
93
- it {results["maggie.simpson@gmail.com"][:creates].should be(7)}
94
- it {results["maggie.simpson@gmail.com"][:deletes].should be(2)}
95
- it {results["maggie.simpson@gmail.com"][:renames].should be(3)}
96
- it {results["maggie.simpson@gmail.com"][:copies].should be(1)}
97
- it {results["maggie.simpson@gmail.com"][:merges].should be(0)}
98
-
99
- end
100
-
101
- context "no merge" do
102
- commits = Commits.new
103
- commits.load(fixture("many_authors.json"))
104
- results = commits.authors_statistics(true, false)
105
-
106
- it {results.size.should be(3)}
107
- it {results["bart.simpson@gmail.com"][:commits].should be(1)}
108
- it {results["bart.simpson@gmail.com"][:insertions].should be(3)}
109
- it {results["bart.simpson@gmail.com"][:deletions].should be(2)}
110
- it {results["bart.simpson@gmail.com"][:creates].should be(2)}
111
- it {results["bart.simpson@gmail.com"][:deletes].should be(0)}
112
- it {results["bart.simpson@gmail.com"][:renames].should be(0)}
113
- it {results["bart.simpson@gmail.com"][:copies].should be(0)}
114
- it {results["bart.simpson@gmail.com"][:merges].should be(0)}
115
-
116
- it {results["kevin.j.jalbert@gmail.com"][:commits].should be(0)}
117
- it {results["kevin.j.jalbert@gmail.com"][:insertions].should be(0)}
118
- it {results["kevin.j.jalbert@gmail.com"][:deletions].should be(0)}
119
- it {results["kevin.j.jalbert@gmail.com"][:creates].should be(0)}
120
- it {results["kevin.j.jalbert@gmail.com"][:deletes].should be(0)}
121
- it {results["kevin.j.jalbert@gmail.com"][:renames].should be(0)}
122
- it {results["kevin.j.jalbert@gmail.com"][:copies].should be(0)}
123
- it {results["kevin.j.jalbert@gmail.com"][:merges].should be(0)}
124
-
125
- it {results["maggie.simpson@gmail.com"][:commits].should be(2)}
126
- it {results["maggie.simpson@gmail.com"][:insertions].should be(211)}
127
- it {results["maggie.simpson@gmail.com"][:deletions].should be(192)}
128
- it {results["maggie.simpson@gmail.com"][:creates].should be(7)}
129
- it {results["maggie.simpson@gmail.com"][:deletes].should be(2)}
130
- it {results["maggie.simpson@gmail.com"][:renames].should be(3)}
131
- it {results["maggie.simpson@gmail.com"][:copies].should be(1)}
132
- it {results["maggie.simpson@gmail.com"][:merges].should be(0)}
133
- end
134
- end
135
-
136
- context "no email" do
137
- context "with merge" do
138
- commits = Commits.new
139
- commits.load(fixture("many_authors.json"))
140
- results = commits.authors_statistics(false, true)
141
-
142
- it {results.size.should be(3)}
143
- it {results["Bart Simpson"][:commits].should be(2)}
144
- it {results["Bart Simpson"][:insertions].should be(13)}
145
- it {results["Bart Simpson"][:deletions].should be(3)}
146
- it {results["Bart Simpson"][:creates].should be(2)}
147
- it {results["Bart Simpson"][:deletes].should be(0)}
148
- it {results["Bart Simpson"][:renames].should be(2)}
149
- it {results["Bart Simpson"][:copies].should be(0)}
150
- it {results["Bart Simpson"][:merges].should be(1)}
151
-
152
- it {results["Kevin Jalbert"][:commits].should be(1)}
153
- it {results["Kevin Jalbert"][:insertions].should be(62)}
154
- it {results["Kevin Jalbert"][:deletions].should be(6)}
155
- it {results["Kevin Jalbert"][:creates].should be(0)}
156
- it {results["Kevin Jalbert"][:deletes].should be(1)}
157
- it {results["Kevin Jalbert"][:renames].should be(0)}
158
- it {results["Kevin Jalbert"][:copies].should be(0)}
159
- it {results["Kevin Jalbert"][:merges].should be(1)}
160
-
161
- it {results["Maggie Simpson"][:commits].should be(2)}
162
- it {results["Maggie Simpson"][:insertions].should be(211)}
163
- it {results["Maggie Simpson"][:deletions].should be(192)}
164
- it {results["Maggie Simpson"][:creates].should be(7)}
165
- it {results["Maggie Simpson"][:deletes].should be(2)}
166
- it {results["Maggie Simpson"][:renames].should be(3)}
167
- it {results["Maggie Simpson"][:copies].should be(1)}
168
- it {results["Maggie Simpson"][:merges].should be(0)}
169
-
170
- end
171
-
172
- context "no merge" do
173
- commits = Commits.new
174
- commits.load(fixture("many_authors.json"))
175
- results = commits.authors_statistics(false, false)
176
-
177
- it {results.size.should be(3)}
178
- it {results["Bart Simpson"][:commits].should be(1)}
179
- it {results["Bart Simpson"][:insertions].should be(3)}
180
- it {results["Bart Simpson"][:deletions].should be(2)}
181
- it {results["Bart Simpson"][:creates].should be(2)}
182
- it {results["Bart Simpson"][:deletes].should be(0)}
183
- it {results["Bart Simpson"][:renames].should be(0)}
184
- it {results["Bart Simpson"][:copies].should be(0)}
185
- it {results["Bart Simpson"][:merges].should be(0)}
186
-
187
- it {results["Kevin Jalbert"][:commits].should be(0)}
188
- it {results["Kevin Jalbert"][:insertions].should be(0)}
189
- it {results["Kevin Jalbert"][:deletions].should be(0)}
190
- it {results["Kevin Jalbert"][:creates].should be(0)}
191
- it {results["Kevin Jalbert"][:deletes].should be(0)}
192
- it {results["Kevin Jalbert"][:renames].should be(0)}
193
- it {results["Kevin Jalbert"][:copies].should be(0)}
194
- it {results["Kevin Jalbert"][:merges].should be(0)}
195
-
196
- it {results["Maggie Simpson"][:commits].should be(2)}
197
- it {results["Maggie Simpson"][:insertions].should be(211)}
198
- it {results["Maggie Simpson"][:deletions].should be(192)}
199
- it {results["Maggie Simpson"][:creates].should be(7)}
200
- it {results["Maggie Simpson"][:deletes].should be(2)}
201
- it {results["Maggie Simpson"][:renames].should be(3)}
202
- it {results["Maggie Simpson"][:copies].should be(1)}
203
- it {results["Maggie Simpson"][:merges].should be(0)}
204
- end
205
- end
206
- end
207
-
208
- describe "#author_top_n_type" do
209
- context "no data" do
210
- context "with email" do
211
- commits = Commits.new
212
- results = commits.author_top_n_type(true, :commits)
213
-
214
- it { results.should be(nil)}
215
- end
216
-
217
- context "without email" do
218
- commits = Commits.new
219
- results = commits.author_top_n_type(false, :commits)
220
-
221
- it { results.should be(nil)}
222
- end
223
- end
224
-
225
- context "with data" do
226
- context "with email" do
227
- context "n is negative" do
228
- commits = Commits.new
229
- commits.load(fixture("many_authors.json"))
230
- commits.calculate_statistics(true, true)
231
- results = commits.author_top_n_type(true, :commits, -1)
232
-
233
- it { results.size.should be(3)}
234
- it { results[0][0].should == "bart.simpson@gmail.com"}
235
- it { results[1][0].should == "maggie.simpson@gmail.com"}
236
- it { results[2][0].should == "kevin.j.jalbert@gmail.com"}
237
-
238
- end
239
-
240
- context "n is 0" do
241
- commits = Commits.new
242
- commits.load(fixture("many_authors.json"))
243
- commits.calculate_statistics(true, true)
244
- results = commits.author_top_n_type(true, :commits, 0)
245
-
246
- it { results.size.should be(3)}
247
- it { results[0][0].should == "bart.simpson@gmail.com"}
248
- it { results[1][0].should == "maggie.simpson@gmail.com"}
249
- it { results[2][0].should == "kevin.j.jalbert@gmail.com"}
250
- end
251
-
252
- context "n is less then total" do
253
- commits = Commits.new
254
- commits.load(fixture("many_authors.json"))
255
- commits.calculate_statistics(true, true)
256
- results = commits.author_top_n_type(true, :commits, 2)
257
-
258
- it { results.size.should be(2)}
259
- it { results[0][0].should == "bart.simpson@gmail.com"}
260
- it { results[1][0].should == "maggie.simpson@gmail.com"}
261
- end
262
-
263
- context "n is greater then total" do
264
- commits = Commits.new
265
- commits.load(fixture("many_authors.json"))
266
- commits.calculate_statistics(true, true)
267
- results = commits.author_top_n_type(true, :commits, 20)
268
-
269
- it { results.size.should be(3)}
270
- it { results[0][0].should == "bart.simpson@gmail.com"}
271
- it { results[1][0].should == "maggie.simpson@gmail.com"}
272
- it { results[2][0].should == "kevin.j.jalbert@gmail.com"}
273
- end
274
- end
275
-
276
- context "no email" do
277
- context "n is negative" do
278
- commits = Commits.new
279
- commits.load(fixture("many_authors.json"))
280
- commits.calculate_statistics(false, true)
281
- results = commits.author_top_n_type(false, :commits, -1)
282
-
283
- it { results.size.should be(3)}
284
- it { results[0][0].should == "Bart Simpson"}
285
- it { results[1][0].should == "Maggie Simpson"}
286
- it { results[2][0].should == "Kevin Jalbert"}
287
-
288
- end
289
-
290
- context "n is 0" do
291
- commits = Commits.new
292
- commits.load(fixture("many_authors.json"))
293
- commits.calculate_statistics(false, true)
294
- results = commits.author_top_n_type(false, :commits, 0)
295
-
296
- it { results.size.should be(3)}
297
- it { results[0][0].should == "Bart Simpson"}
298
- it { results[1][0].should == "Maggie Simpson"}
299
- it { results[2][0].should == "Kevin Jalbert"}
300
- end
301
-
302
- context "n is less then total" do
303
- commits = Commits.new
304
- commits.load(fixture("many_authors.json"))
305
- commits.calculate_statistics(false, true)
306
- results = commits.author_top_n_type(false, :commits, 2)
307
-
308
- it { results.size.should be(2)}
309
- it { results[0][0].should == "Bart Simpson"}
310
- it { results[1][0].should == "Maggie Simpson"}
311
- end
312
-
313
- context "n is greater then total" do
314
- commits = Commits.new
315
- commits.load(fixture("many_authors.json"))
316
- commits.calculate_statistics(false, true)
317
- results = commits.author_top_n_type(false, :commits, 20)
318
-
319
- it { results.size.should be(3)}
320
- it { results[0][0].should == "Bart Simpson"}
321
- it { results[1][0].should == "Maggie Simpson"}
322
- it { results[2][0].should == "Kevin Jalbert"}
323
- end
324
- end
325
- end
326
- end
327
-
328
- describe "#calculate_statistics (totals)" do
329
- context "with merge" do
330
- commits = Commits.new
331
- commits.load(fixture("many_authors.json"))
332
- commits.calculate_statistics(true, true)
333
- results = commits.totals
334
-
335
- it {results[:commits].should be(5)}
336
- it {results[:insertions].should be(286)}
337
- it {results[:deletions].should be(201)}
338
- it {results[:creates].should be(9)}
339
- it {results[:deletes].should be(3)}
340
- it {results[:renames].should be(5)}
341
- it {results[:copies].should be(1)}
342
- it {results[:merges].should be(2)}
343
- end
344
-
345
- context "no merge" do
346
- commits = Commits.new
347
- commits.load(fixture("many_authors.json"))
348
- commits.calculate_statistics(false, false)
349
- results = commits.totals
350
-
351
- it {results[:commits].should be(3)}
352
- it {results[:insertions].should be(214)}
353
- it {results[:deletions].should be(194)}
354
- it {results[:creates].should be(9)}
355
- it {results[:deletes].should be(2)}
356
- it {results[:renames].should be(3)}
357
- it {results[:copies].should be(1)}
358
- it {results[:merges].should be(0)}
359
- end
360
- end
361
-
362
- describe "#save" do
363
- context "with pretty" do
364
- commits = Commits.new
365
- commits.load(fixture("single_author.json"))
366
- commits.save("tmp.json", true)
367
- same = FileUtils.compare_file("tmp.json", fixture("single_author.json"))
368
- FileUtils.remove_file("tmp.json")
369
- it { same.should be_true }
370
- end
371
-
372
- context "no pretty" do
373
- commits = Commits.new
374
- commits.load(fixture("single_author.json"))
375
- commits.save("tmp.json", false)
376
- same = FileUtils.compare_file("tmp.json", fixture("single_author_unpretty.json"))
377
- FileUtils.remove_file("tmp.json")
378
- it { same.should be_true }
379
- end
380
- end
381
- end
@@ -1,62 +0,0 @@
1
- {
2
- "49164f12e4cd3b253e5de31242bc716c9e7d6f95": {
3
- "author": "Bart Simpson",
4
- "author_email": "bart.simpson@gmail.com",
5
- "time": "2012-04-06 11:58:16 -0400",
6
- "insertions": 3,
7
- "deletions": 2,
8
- "creates": 2,
9
- "deletes": 0,
10
- "renames": 0,
11
- "copies": 0,
12
- "merge": false
13
- },
14
- "642276027055befb50999c7c155391402bb7c2e8": {
15
- "author": "Kevin Jalbert",
16
- "author_email": "kevin.j.jalbert@gmail.com",
17
- "time": "2012-04-09 21:02:42 -0400",
18
- "insertions": 62,
19
- "deletions": 6,
20
- "creates": 0,
21
- "deletes": 1,
22
- "renames": 0,
23
- "copies": 0,
24
- "merge": true
25
- },
26
- "754e18e83c748700d883048dbc889c7b0db7121d": {
27
- "author": "Bart Simpson",
28
- "author_email": "bart.simpson@gmail.com",
29
- "time": "2012-04-09 21:15:46 -0400",
30
- "insertions": 10,
31
- "deletions": 1,
32
- "creates": 0,
33
- "deletes": 0,
34
- "renames": 2,
35
- "copies": 0,
36
- "merge": true
37
- },
38
- "f9e638cd4bf18d4f6db27a9c085a9f558f762cc3": {
39
- "author": "Maggie Simpson",
40
- "author_email": "maggie.simpson@gmail.com",
41
- "time": "2012-04-09 21:42:07 -0400",
42
- "insertions": 8,
43
- "deletions": 5,
44
- "creates": 4,
45
- "deletes": 1,
46
- "renames": 2,
47
- "copies": 1,
48
- "merge": false
49
- },
50
- "fba10799b65b0e50c8dc355c9acae08d22b193ae": {
51
- "author": "Maggie Simpson",
52
- "author_email": "maggie.simpson@gmail.com",
53
- "time": "2012-04-11 11:48:07 -0400",
54
- "insertions": 203,
55
- "deletions": 187,
56
- "creates": 3,
57
- "deletes": 1,
58
- "renames": 1,
59
- "copies": 0,
60
- "merge": false
61
- }
62
- }
@@ -1,26 +0,0 @@
1
- {
2
- "f9e638cd4bf18d4f6db27a9c085a9f558f762cc3": {
3
- "author": "Kevin Jalbert",
4
- "author_email": "kevin.j.jalbert@gmail.com",
5
- "time": "2012-04-09 21:42:07 -0400",
6
- "insertions": 8,
7
- "deletions": 5,
8
- "creates": 0,
9
- "deletes": 0,
10
- "renames": 0,
11
- "copies": 0,
12
- "merge": false
13
- },
14
- "fba10799b65b0e50c8dc355c9acae08d22b193ae": {
15
- "author": "Kevin Jalbert",
16
- "author_email": "kevin.j.jalbert@gmail.com",
17
- "time": "2012-04-11 11:48:07 -0400",
18
- "insertions": 203,
19
- "deletions": 187,
20
- "creates": 3,
21
- "deletes": 1,
22
- "renames": 1,
23
- "copies": 0,
24
- "merge": false
25
- }
26
- }
@@ -1 +0,0 @@
1
- {"f9e638cd4bf18d4f6db27a9c085a9f558f762cc3":{"author":"Kevin Jalbert","author_email":"kevin.j.jalbert@gmail.com","time":"2012-04-09 21:42:07 -0400","insertions":8,"deletions":5,"creates":0,"deletes":0,"renames":0,"copies":0,"merge":false},"fba10799b65b0e50c8dc355c9acae08d22b193ae":{"author":"Kevin Jalbert","author_email":"kevin.j.jalbert@gmail.com","time":"2012-04-11 11:48:07 -0400","insertions":203,"deletions":187,"creates":3,"deletes":1,"renames":1,"copies":0,"merge":false}}